Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

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

Prototype

Color LIGHT_GRAY

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

Click Source Link

Document

The color light gray.

Usage

From source file:com.rapidminer.gui.plotter.charts.HistogramColorChart.java

@Override
protected void updatePlotter() {
    prepareData();//  w  w w  .j  a va2  s.co m

    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Deviation plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.HistogramColorChart.parsing_property_error");
    }

    JFreeChart chart = null;
    if (nominal) {
        // ** nominal **
        int categoryCount = this.categoryDataset.getRowCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";

        chart = ChartFactory.createBarChart(null, // title
                domainName, "Frequency", categoryDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        BarRenderer renderer = new BarRenderer();
        if (categoryDataset.getRowCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (categoryDataset.getRowCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }
    } else {
        // ** numerical **
        int categoryCount = this.histogramDataset.getSeriesCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";
        chart = ChartFactory.createHistogram(null, // title
                domainName, "Frequency", histogramDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        XYPlot plot = chart.getXYPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        XYBarRenderer renderer = new XYBarRenderer();
        if (histogramDataset.getSeriesCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < histogramDataset.getSeriesCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (histogramDataset.getSeriesCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidXYBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // Correctly displays dates on x-axis
        if (datetime) {
            DateAxis dateAxis = new DateAxis();
            dateAxis.setDateFormatOverride(Tools.DATE_TIME_FORMAT.get());
            plot.setDomainAxis(dateAxis);
        }

        // range axis
        Range range = getRangeForDimension(valueColumn);
        if (range != null) {
            plot.getDomainAxis().setRange(range);
        }

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setVerticalTickLabels(true);
        }

        if (histogramDataset.getSeriesCount() == 1) {
            String key = histogramDataset.getSeriesKey(0).toString();
            int index = this.dataTable.getColumnIndex(key);
            if (index >= 0) {
                if (this.dataTable.isNominal(index)) {
                    String[] values = new String[dataTable.getNumberOfValues(index)];
                    for (int i = 0; i < values.length; i++) {
                        values[i] = dataTable.mapIndex(index, i);
                    }
                    plot.setDomainAxis(new SymbolAxis(key, values));

                    // rotate labels
                    if (isLabelRotating()) {
                        plot.getDomainAxis().setTickLabelsVisible(true);
                        plot.getDomainAxis().setVerticalTickLabels(true);
                    }
                }
            }
        }
    }

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // Disable zooming for Histogram-Charts
    panel.setRangeZoomable(false);
    panel.setDomainZoomable(false);

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:de.brazzy.nikki.model.ImageReader.java

/**
 * Scales image to given size, preserving aspec ratio
 * /*from   w  ww.j av  a2s  . co m*/
 * @param toWidth
 *            width to scale to
 * @param paintBorder
 *            whether to paint an etched border around the image
 * @param isThumbnail
 *            if true, faster low-quality scaling will be used
 */
public byte[] scale(int toWidth, boolean paintBorder, boolean isThumbnail)
        throws IOException, LLJTranException {
    readMainImage();

    int toHeight = heightForWidth(mainImage, toWidth);

    BufferedImageOp op = isThumbnail ? new ThumpnailRescaleOp(toWidth, toHeight)
            : new ResampleOp(toWidth, toHeight);

    BufferedImage scaledImage = op.filter(mainImage, null);
    if (paintBorder) {
        Graphics2D g = scaledImage.createGraphics();
        g.setPaintMode();
        new EtchedBorder(EtchedBorder.RAISED, Color.LIGHT_GRAY, Color.DARK_GRAY).paintBorder(null, g, 0, 0,
                toWidth, toHeight);
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ImageIO.write(scaledImage, "jpg", out);
    return adjustForRotation(out.toByteArray());
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.MIFNotificationDialog.java

/**
 * Lays out the thumbnails.//from w  ww  .j a  va  2  s . co m
 * 
 * @param n The number of images not listed.
 * @param thumbnails The objects to lay out.
 */
private JPanel layoutThumbnails(int n, List<ThumbnailData> thumbnails) {
    JPanel row = createRow();
    row.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    Iterator<ThumbnailData> i = thumbnails.iterator();
    ThumbnailLabel label;
    while (i.hasNext()) {
        label = new ThumbnailLabel();
        label.setData(i.next());
        label.setToolTipText("");
        row.add(label);
    }
    if (n > 0)
        row.add(new JLabel("..."));
    return row;
}

From source file:net.frontlinesms.plugins.textforms.ui.ManageTextFormsPanelHandler.java

public void focusLost(Object textfield) {
    String searchText = this.ui.getText(textfield);
    if (searchText == null || searchText.length() == 0) {
        this.ui.setText(textfield, TextFormsMessages.getMessageSearchTextForms());
        this.ui.setForeground(Color.LIGHT_GRAY);
    } else {//from www. jav a  2  s  .  co  m
        this.ui.setForeground(Color.BLACK);
    }
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    cnt2++;
                }
                cnt++;
            }

        backing_g.setClip(null);
    }
}

From source file:edu.ku.brc.specify.plugins.TaxonLabelFormatting.java

@Override
public void initialize(Properties propertiesArg, boolean isViewModeArg) {
    super.initialize(propertiesArg, isViewModeArg);

    String plName = "TaxonLabelFormatter";
    PickListDBAdapterIFace adapter = PickListDBAdapterFactory.getInstance().create(plName, false);
    if (adapter == null || adapter.getPickList() == null) {
        throw new RuntimeException("PickList Adapter [" + plName + "] cannot be null!");
    }/*from   w  w  w .ja  va 2  s  .c  o m*/
    formatCBX = new ValComboBox(adapter);
    formatCBX.getComboBox().addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doFormatting();
        }
    });
    formatCBX.getComboBox().addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            doFormatting();
        }
    });

    newAgentBtn = createButton(""); // Label set when new Resource Bundle is installed (below)
    searchPanel = new DBObjSearchPanel("Search", "AgentNameSearch", "AgentNameSearch",
            "edu.ku.brc.specify.datamodel.Agent", "agentId", SwingConstants.BOTTOM);
    searchPanel.getScrollPane().setMinimumSize(new Dimension(100, 200));
    searchPanel.getScrollPane().setPreferredSize(new Dimension(100, 150));
    ((FormViewObj) searchPanel.getForm()).getPanel().setBorder(null);

    try {
        UIRegistry.loadAndPushResourceBundle("specify_plugins");

        newAgentBtn.setText(getResourceString("NewAgent"));

        authorsList = new JList(new DefaultListModel());
        authorsList.setVisibleRowCount(10);
        authorsList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    Object selObj = authorsList.getSelectedValue();
                    if (selObj != null) {

                    }
                    updateEnabledState();
                }
            }
        });
        JScrollPane scrollPane = new JScrollPane(authorsList, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        mapToBtn = createIconBtn("Map", "ADD_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                Object agent = searchPanel.getSelectedObject();
                ((DefaultListModel) authorsList.getModel()).addElement(agent);
                doFormatting();
            }
        });
        unmapBtn = createIconBtn("Unmap", "REMOVE_AUTHOR_NAME_TT", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                int index = authorsList.getSelectedIndex();
                if (index > -1) {
                    DefaultListModel model = (DefaultListModel) authorsList.getModel();
                    model.remove(index);
                    updateEnabledState();
                    doFormatting();
                }
            }
        });

        upBtn = createIconBtn("ReorderUp", "MOVE_AUTHOR_NAME_UP", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index - 1);
                authorsList.setSelectedIndex(index - 1);
                updateEnabledState();
            }
        });
        downBtn = createIconBtn("ReorderDown", "MOVE_AUTHOR_NAME_DOWN", new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DefaultListModel model = (DefaultListModel) authorsList.getModel();
                int index = authorsList.getSelectedIndex();
                Object item = authorsList.getSelectedValue();
                model.remove(index);
                model.insertElementAt(item, index + 1);
                authorsList.setSelectedIndex(index + 1);
                updateEnabledState();
            }
        });

        PanelBuilder bldr = new PanelBuilder(new FormLayout("p, 5px, p, 5px, f:p:g, 2px, p",
                "p, 4px, p, 2px, f:p:g, 4px, p, 4px, p, 2px, p, 2px, p, 2px, p"), this);
        CellConstraints cc = new CellConstraints();

        PanelBuilder upDownPanel = new PanelBuilder(new FormLayout("p", "p, 2px, p, f:p:g"));
        upDownPanel.add(upBtn, cc.xy(1, 1));
        upDownPanel.add(downBtn, cc.xy(1, 3));

        PanelBuilder middlePanel = new PanelBuilder(new FormLayout("c:p:g", "f:p:g, p, 2px, p, f:p:g"));
        middlePanel.add(mapToBtn, cc.xy(1, 2));
        middlePanel.add(unmapBtn, cc.xy(1, 4));

        PanelBuilder rwPanel = new PanelBuilder(new FormLayout("p, 2px, f:p:g", "p"));
        refWorkLabel = createLabel(getResourceString("NONE"));
        rwPanel.add(createI18NFormLabel("REFERENCEWORK"), cc.xy(1, 1));
        rwPanel.add(refWorkLabel, cc.xy(3, 1));

        int y = 1;

        bldr.add(rwPanel.getPanel(), cc.xywh(1, y, 7, 1));
        y += 2;

        bldr.add(searchPanel, cc.xywh(1, y, 1, 3));
        bldr.addSeparator(getResourceString("Authors"), cc.xy(5, y));
        y += 2;

        bldr.add(middlePanel.getPanel(), cc.xy(3, y));
        bldr.add(scrollPane, cc.xywh(5, y, 1, 3));
        bldr.add(upDownPanel.getPanel(), cc.xy(7, y));
        y += 2;

        PanelBuilder newAgentPanel = new PanelBuilder(new FormLayout("f:p:g,p", "p"));
        newAgentPanel.add(newAgentBtn, cc.xy(2, 1));

        bldr.add(newAgentPanel.getPanel(), cc.xy(1, y));
        y += 2;

        JLabel fmtLabel = createLabel(getResourceString("LABELFORMAT"));
        bldr.add(fmtLabel, cc.xy(1, y));
        y += 2;
        bldr.add(formatCBX, cc.xywh(1, y, 7, 1));
        y += 2;

        Font plain = fmtLabel.getFont();
        specialLabel = new SpecialLabel(plain, new Font(plain.getName(), Font.ITALIC, plain.getSize()));
        specialLabel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
        bldr.add(createLabel(getResourceString("SAMPLEOUTPUT") + ":"), cc.xywh(1, y, 7, 1));
        y += 2;
        bldr.add(specialLabel, cc.xywh(1, y, 7, 1));

        searchPanel.setOKBtn(mapToBtn);
    } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(TaxonLabelFormatting.class, ex);
        log.error(ex);
        ex.printStackTrace();
    }
    UIRegistry.popResourceBundle();
}

From source file:gg.view.categoriesbalances.GraphCategoriesBalancesTopComponent.java

/**
 * Displays the categories/sub-categories' balances by period
 * @param balances Categories' balances// w w w  .  j  av  a2 s . c  o m
 */
private void displayData(Map<Long, Map<SearchCriteria, BigDecimal>> balances) {
    log.info("Categories' balances graph computed and displayed");

    // Display hourglass cursor
    Utilities.changeCursorWaitStatus(true);

    // Create the dataset (that will contain the categories/sub-categories' balances)
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // Create an empty chart
    JFreeChart chart = ChartFactory.createLineChart("", // chart title
            "", // x axis label
            NbBundle.getMessage(GraphCategoriesBalancesTopComponent.class,
                    "GraphAccountsBalancesTopComponent.Amount"), // y axis label
            dataset, // data displayed in the chart
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // Chart color
    chart.setBackgroundPaint(jPanelCategoriesBalances.getBackground());
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);

    // Grid lines
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // Set the orientation of the categories on the domain axis (X axis)
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // Add the series on the chart for each category/sub-category displayed in the table
    for (Long categoryId : balances.keySet()) {
        Category category = Wallet.getInstance().getCategoriesWithId().get(categoryId);
        assert (category != null);

        SortedSet<SearchCriteria> sortedSearchCriteria = new TreeSet<SearchCriteria>(
                balances.get(categoryId).keySet());
        for (SearchCriteria searchCriteria : sortedSearchCriteria) {

            if ((!searchCriteria.hasCategoriesFilter() && category.isTopCategory()
                    && !category.getSystemProperty()) || searchCriteria.getCategories().contains(category)) {

                BigDecimal balance = new BigDecimal(0);
                if (balances.get(categoryId) != null && balances.get(categoryId).get(searchCriteria) != null) {
                    balance = balances.get(categoryId).get(searchCriteria);
                }

                dataset.addValue(balance, category.getName(), searchCriteria.getPeriod());
            }
        }
    }

    // Series' shapes
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    for (int i = 0; i < dataset.getRowCount(); i++) {
        renderer.setSeriesShapesVisible(i, true);
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond(2F));
    }
    // Set the scale of the chart
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Create the chart panel that contains the chart
    ChartPanel chartPanel = new ChartPanel(chart);

    // Display the chart
    jPanelCategoriesBalances.removeAll();
    jPanelCategoriesBalances.add(chartPanel, BorderLayout.CENTER);
    jPanelCategoriesBalances.updateUI();

    // Display normal cursor
    Utilities.changeCursorWaitStatus(false);
}

From source file:org.openmicroscopy.shoola.agents.util.ui.ScriptComponent.java

/** Builds and lays out the UI. */
void buildUI() {//  w ww . j  av a 2  s .co  m
    int width = TAB * getTabulationLevel();
    if (DEFAULT_TEXT.equals(name))
        width = 0;
    if (CollectionUtils.isEmpty(children)) {
        double[][] size = { { width, TableLayout.PREFERRED, 5, TableLayout.FILL }, { TableLayout.PREFERRED } };
        setLayout(new TableLayout(size));
        add(Box.createHorizontalStrut(width), "0, 0");
        add(getLabel(), "1, 0");
        add(getComponent(), "3, 0");
    } else {
        //create a row.
        double[][] size = { { TableLayout.FILL }, { TableLayout.PREFERRED } };
        TableLayout layout = new TableLayout(size);
        setLayout(layout);
        Iterator<ScriptComponent> i = children.iterator();
        ScriptComponent child;
        setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
        add(createRow(), "0, 0");
        int index = 1;
        while (i.hasNext()) {
            child = i.next();
            child.buildUI();
            layout.insertRow(index, TableLayout.PREFERRED);
            add(child, "0, " + index);
            index++;
        }
    }
}

From source file:keel.Algorithms.UnsupervisedLearning.AssociationRules.Visualization.keelassotiationrulesboxplot.ResultsProccessor.java

public void writeToFile(String outName)
        throws FileNotFoundException, UnsupportedEncodingException, IOException {
    //calcMeans();

    // Create JFreeChart Dataset
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();

    HashMap<String, ArrayList<Double>> measuresFirst = algorithmMeasures.entrySet().iterator().next()
            .getValue();/*from   w w  w. j  a  v  a2  s . co  m*/
    for (Map.Entry<String, ArrayList<Double>> measure : measuresFirst.entrySet()) {
        String measureName = measure.getKey();
        //Double measureValue = measure.getValue();
        dataset.clear();

        for (Map.Entry<String, HashMap<String, ArrayList<Double>>> entry : algorithmMeasures.entrySet()) {
            String alg = entry.getKey();
            ArrayList<Double> measureValues = entry.getValue().get(measureName);

            // Parse algorithm name to show it correctly
            String aName = alg.substring(0, alg.length() - 1);
            int startAlgName = aName.lastIndexOf("/");
            aName = aName.substring(startAlgName + 1);

            dataset.add(measureValues, aName, measureName);
        }

        // Tutorial: http://www.java2s.com/Code/Java/Chart/JFreeChartBoxAndWhiskerDemo.htm
        final CategoryAxis xAxis = new CategoryAxis("Algorithm");
        final NumberAxis yAxis = new NumberAxis("Value");
        yAxis.setAutoRangeIncludesZero(false);
        final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();

        // Black and White
        int numItems = algorithmMeasures.size();
        for (int i = 0; i < numItems; i++) {
            Color color = Color.DARK_GRAY;
            if (i % 2 == 1) {
                color = Color.LIGHT_GRAY;
            }
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesOutlinePaint(i, Color.BLACK);
        }

        renderer.setMeanVisible(false);
        renderer.setFillBox(false);
        renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
        final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

        Font font = new Font("SansSerif", Font.BOLD, 10);
        //ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
        JFreeChart jchart = new JFreeChart("Assotiation Rules Measures - BoxPlot", font, plot, true);
        //StandardChartTheme.createLegacyTheme().apply(jchart);

        int width = 640 * 2; /* Width of the image */
        int height = 480 * 2; /* Height of the image */

        // JPEG
        File chart = new File(outName + "_" + measureName + "_boxplot.jpg");
        ChartUtilities.saveChartAsJPEG(chart, jchart, width, height);

        // SVG
        SVGGraphics2D g2 = new SVGGraphics2D(width, height);
        Rectangle r = new Rectangle(0, 0, width, height);
        jchart.draw(g2, r);
        File BarChartSVG = new File(outName + "_" + measureName + "_boxplot.svg");
        SVGUtils.writeToSVG(BarChartSVG, g2.getSVGElement());
    }

}

From source file:org.sleuthkit.autopsy.experimental.autoingest.FileExporterSettingsPanel.java

public FileExporterSettingsPanel(JDialog jDialog) {
    timeSettings.setFormatForDisplayTime(
            PickerUtilities.createFormatterFromPatternString("HH:mm:ss", timeSettings.getLocale()));
    timeSettings.setFormatForMenuTimes(/*  ww  w.ja v a  2 s  . c  om*/
            PickerUtilities.createFormatterFromPatternString("HH:mm", timeSettings.getLocale()));

    initComponents();
    rootNode = new DefaultMutableTreeNode(new Item(ROOTNODE, ROOTNODE, ItemType.RULE_SET));
    trRuleList.setModel(new DefaultTreeModel(rootNode));
    this.jDialog = jDialog;

    attributeListModel = (DefaultListModel<String>) lsAttributeList.getModel();

    rootDirectoryChooser
            .setCurrentDirectory(rootDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS
    rootDirectoryChooser.setAcceptAllFileFilterUsed(false);
    rootDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class,
            "FileExporterSettingsPanel.ChooseRootDirectory"));
    rootDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    reportDirectoryChooser.setCurrentDirectory(
            reportDirectoryChooser.getFileSystemView().getParentDirectory(new File("C:\\"))); //NON-NLS
    reportDirectoryChooser.setAcceptAllFileFilterUsed(false);
    reportDirectoryChooser.setDialogTitle(NbBundle.getMessage(FileExporterSettingsPanel.class,
            "FileExporterSettingsPanel.ChooseReportDirectory"));
    reportDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    // Add text prompt to the text box fields
    TextPrompt textPromptRuleName = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RuleName"),
            tbRuleName);
    textPromptRuleName.setForeground(Color.LIGHT_GRAY);
    textPromptRuleName.changeAlpha(0.9f);

    TextPrompt textPromptRootDirectory = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.RootDirectory"),
            tbRootDirectory);
    textPromptRootDirectory.setForeground(Color.LIGHT_GRAY);
    textPromptRootDirectory.changeAlpha(0.9f);

    TextPrompt textPromptReportDirectory = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.ReportDirectory"),
            tbReportDirectory);
    textPromptReportDirectory.setForeground(Color.LIGHT_GRAY);
    textPromptReportDirectory.changeAlpha(0.9f);

    TextPrompt textPromptReportAttributeValue = new TextPrompt(
            NbBundle.getMessage(FileExporterSettingsPanel.class, "FileExporterSettingsPanel.AttributeValue"),
            tbAttributeValue);
    textPromptReportAttributeValue.setForeground(Color.LIGHT_GRAY);
    textPromptReportAttributeValue.changeAlpha(0.9f);

    for (SizeUnit item : SizeUnit.values()) {
        comboBoxFileSizeUnits.addItem(item.toString());
    }

    for (RelationalOp item : RelationalOp.values()) {
        comboBoxFileSizeComparison.addItem(item.getSymbol());
        comboBoxAttributeComparison.addItem(item.getSymbol());
    }

    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.INTEGER.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.LONG.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DOUBLE.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.STRING.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME.getLabel());
    comboBoxValueType.addItem(BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.BYTE.getLabel());
    comboBoxValueType.addItem(UNSET);

    load();
    trRuleList.setCellRenderer(new DefaultTreeCellRenderer() {
        private static final long serialVersionUID = 1L;
        private final ImageIcon ruleSetIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/ruleset-icon.png", false));
        private final ImageIcon ruleIcon = new ImageIcon(ImageUtilities
                .loadImage("org/sleuthkit/autopsy/experimental/images/extracted_content.png", false));
        private final ImageIcon sizeIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/file-size-16.png", false));
        private final ImageIcon artifactIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/artifact-icon.png", false));
        private final ImageIcon mimetypeIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/mime-icon.png", false));
        private final ImageIcon otherIcon = new ImageIcon(
                ImageUtilities.loadImage("org/sleuthkit/autopsy/experimental/images/knownbad-icon.png", false));

        @Override
        public Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean selected,
                boolean expanded, boolean isLeaf, int row, boolean focused) {
            Component component = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf,
                    row, focused);
            Icon icon;
            switch (((Item) ((DefaultMutableTreeNode) value).getUserObject()).getItemType()) {
            case ARTIFACT_CLAUSE:
                icon = artifactIcon;
                break;
            case MIME_TYPE_CLAUSE:
                icon = mimetypeIcon;
                break;
            case RULE:
                icon = ruleIcon;
                break;
            case SIZE_CLAUSE:
                icon = sizeIcon;
                break;
            case RULE_SET:
                icon = ruleSetIcon;
                break;
            default:
                icon = otherIcon;
                break;
            }
            setIcon(icon);
            return component;
        }
    });
    populateMimeTypes();
    populateArtifacts();
    populateAttributes();
    populateRuleTree();

    tbRuleName.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void changedUpdate(DocumentEvent e) {
            setSaveButton();
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            setSaveButton();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            setSaveButton();
        }
    });

    comboBoxMimeValue.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxMimeValue.showPopup();
            comboBoxMimeValue.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxArtifactName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxArtifactName.showPopup();
            comboBoxArtifactName.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxAttributeName.getEditor().getEditorComponent().addFocusListener(new java.awt.event.FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            comboBoxAttributeName.showPopup();
            comboBoxAttributeName.getEditor().selectAll();
        }

        @Override
        public void focusLost(FocusEvent e) {
            // do nothing
        }
    });

    comboBoxMimeTypeComparison.addItem(RelationalOp.Equals.getSymbol());
    comboBoxMimeTypeComparison.addItem(RelationalOp.NotEquals.getSymbol());
    treeSelectionModel = trRuleList.getSelectionModel();
    defaultTreeModel = (DefaultTreeModel) trRuleList.getModel();
    bnDeleteRule.setEnabled(false);
    String selectedAttribute = comboBoxAttributeName.getSelectedItem().toString();
    comboBoxValueType.setSelectedItem(selectedAttribute);
    localRule = makeRuleFromUserInput();

    listSelectionListener = this::lsAttributeListValueChanged;
    lsAttributeList.addListSelectionListener(listSelectionListener);

    treeSelectionListener = this::trRuleListValueChanged;
    trRuleList.addTreeSelectionListener(treeSelectionListener);
    setDeleteAttributeButton();
    setSaveButton();
}