Example usage for java.awt Color BLACK

List of usage examples for java.awt Color BLACK

Introduction

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

Prototype

Color BLACK

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

Click Source Link

Document

The color black.

Usage

From source file:GUI.GraficaView.java

private void init() {
    ArrayList<OperacionesDiarias> aux = operario.getArrayOperacionesDiarias();
    Collections.sort(aux);//w ww .ja v a2  s .com

    panel = new JPanel();
    getContentPane().add(panel);
    // Fuente de Datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (OperacionesDiarias op : aux) {
        if (op.getListaOperaciones().size() > 0) {
            dataset.setValue(op.getPorcentaje(), operario.getNombre(), op.getFecha());
        }

    }

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createBarChart3D("Rendimiento", "Dia", "Porcentaje %", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.LIGHT_GRAY);
    chart.getTitle().setPaint(Color.black);
    CategoryPlot p = chart.getCategoryPlot();
    p.setRangeGridlinePaint(Color.red);

    // Mostrar Grafico
    ChartPanel chartPanel = new ChartPanel(chart);
    panel.add(chartPanel);
    repaint();
}

From source file:cl.almejo.vsim.gui.ColorScheme.java

public ColorScheme(String name) {
    _name = name;/*from w ww .  j av  a 2s . c  o  m*/
    _colors.put("background", Color.GRAY);
    _colors.put("bus-on", Color.RED);
    _colors.put("gates", Color.BLUE);
    _colors.put("ground", Color.GREEN);
    _colors.put("off", Color.BLACK);
    _colors.put("wires-on", Color.RED);
    _colors.put("signal", Color.RED);
    _colors.put("grid", Color.GRAY);
    _colors.put("label", Color.YELLOW);
}

From source file:MouseTest.java

public MouseTest() {
    super();//www .  jav  a2 s. co m

    final JPopupMenu pop = new JPopupMenu();
    pop.add(new JMenuItem("Cut"));
    pop.add(new JMenuItem("Copy"));
    pop.add(new JMenuItem("Paste"));
    pop.addSeparator();
    pop.add(new JMenuItem("Select All"));
    pop.setInvoker(this);

    MouseListener popup = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        private void showPopup(MouseEvent e) {
            pop.show(e.getComponent(), e.getX(), e.getY());
        }
    };
    addMouseListener(popup);

    MouseListener drawing1 = new MouseListener() {
        public void mouseClicked(MouseEvent e) {
        }

        public void mouseEntered(MouseEvent e) {
        }

        public void mouseExited(MouseEvent e) {
        }

        public void mousePressed(MouseEvent e) {
            color = Color.RED;
            startX = endX = e.getX();
            startY = endY = e.getY();
            repaint();
        }

        public void mouseReleased(MouseEvent e) {
            color = Color.BLACK;
            repaint();
        }
    };
    addMouseListener(drawing1);

    MouseMotionListener drawing2 = new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            endX = e.getX();
            endY = e.getY();
            repaint();
        }

        public void mouseMoved(MouseEvent e) {
        }
    };
    addMouseMotionListener(drawing2);

}

From source file:com.aw.swing.mvp.grid.GridManager.java

private void configureLabelFor() {
    //        ipView.getLblTitGrid(gridIndex).setLabelFor(ipView.getChkSelector(gridIndex));
    ipView.getLblTitGrid(gridIndex).setLabelFor(ipView.getTblGrid(gridIndex));
    ipView.getLblTitGrid(gridIndex).setForeground(Color.BLACK);
    //        ipView.getChkSelector(gridIndex).setVisible(false);
}

From source file:CompositeEffects.java

/** Draw the example */
public void paint(Graphics g1) {
    Graphics2D g = (Graphics2D) g1;

    // fill the background
    g.setPaint(new Color(175, 175, 175));
    g.fillRect(0, 0, getWidth(), getHeight());

    // Set text attributes
    g.setColor(Color.black);
    g.setFont(new Font("SansSerif", Font.BOLD, 12));

    // Draw the unmodified image
    g.translate(10, 10);//from   www.j av a 2s. c o  m
    g.drawImage(cover, 0, 0, this);
    g.drawString("SRC_OVER", 0, COVERHEIGHT + 15);

    // Draw the cover again, using AlphaComposite to make the opaque
    // colors of the image 50% translucent
    g.translate(COVERWIDTH + 10, 0);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    g.drawImage(cover, 0, 0, this);

    // Restore the pre-defined default Composite for the screen, so
    // opaque colors stay opaque.
    g.setComposite(AlphaComposite.SrcOver);
    // Label the effect
    g.drawString("SRC_OVER, 50%", 0, COVERHEIGHT + 15);

    // Now get an offscreen image to work with. In order to achieve
    // certain compositing effects, the drawing surface must support
    // transparency. Onscreen drawing surfaces cannot, so we have to do the
    // compositing in an offscreen image that is specially created to have
    // an "alpha channel", then copy the final result to the screen.
    BufferedImage offscreen = new BufferedImage(COVERWIDTH, COVERHEIGHT, BufferedImage.TYPE_INT_ARGB);

    // First, fill the image with a color gradient background that varies
    // left-to-right from opaque to transparent yellow
    Graphics2D osg = offscreen.createGraphics();
    osg.setPaint(new GradientPaint(0, 0, Color.yellow, COVERWIDTH, 0, new Color(255, 255, 0, 0)));
    osg.fillRect(0, 0, COVERWIDTH, COVERHEIGHT);

    // Now copy the cover image on top of this, but use the DstOver rule
    // which draws it "underneath" the existing pixels, and allows the
    // image to show depending on the transparency of those pixels.
    osg.setComposite(AlphaComposite.DstOver);
    osg.drawImage(cover, 0, 0, this);

    // And display this composited image on the screen. Note that the
    // image is opaque and that none of the screen background shows through
    g.translate(COVERWIDTH + 10, 0);
    g.drawImage(offscreen, 0, 0, this);
    g.drawString("DST_OVER", 0, COVERHEIGHT + 15);

    // Now start over and do a new effect with the off-screen image.
    // First, fill the offscreen image with a new color gradient. We
    // don't care about the colors themselves; we just want the
    // translucency of the background to vary. We use opaque black to
    // transparent black. Note that since we've already used this offscreen
    // image, we set the composite to Src, we can fill the image and
    // ignore anything that is already there.
    osg.setComposite(AlphaComposite.Src);
    osg.setPaint(new GradientPaint(0, 0, Color.black, COVERWIDTH, COVERHEIGHT, new Color(0, 0, 0, 0)));
    osg.fillRect(0, 0, COVERWIDTH, COVERHEIGHT);

    // Now set the compositing type to SrcIn, so colors come from the
    // source, but translucency comes from the destination
    osg.setComposite(AlphaComposite.SrcIn);

    // Draw our loaded image into the off-screen image, compositing it.
    osg.drawImage(cover, 0, 0, this);

    // And then copy our off-screen image to the screen. Note that the
    // image is translucent and some of the image shows through.
    g.translate(COVERWIDTH + 10, 0);
    g.drawImage(offscreen, 0, 0, this);
    g.drawString("SRC_IN", 0, COVERHEIGHT + 15);

    // If we do the same thing but use SrcOut, then the resulting image
    // will have the inverted translucency values of the destination
    osg.setComposite(AlphaComposite.Src);
    osg.setPaint(new GradientPaint(0, 0, Color.black, COVERWIDTH, COVERHEIGHT, new Color(0, 0, 0, 0)));
    osg.fillRect(0, 0, COVERWIDTH, COVERHEIGHT);
    osg.setComposite(AlphaComposite.SrcOut);
    osg.drawImage(cover, 0, 0, this);
    g.translate(COVERWIDTH + 10, 0);
    g.drawImage(offscreen, 0, 0, this);
    g.drawString("SRC_OUT", 0, COVERHEIGHT + 15);

    // Here's a cool effect; it has nothing to do with compositing, but
    // uses an arbitrary shape to clip the image. It uses Area to combine
    // shapes into more complicated ones.
    g.translate(COVERWIDTH + 10, 0);
    Shape savedClip = g.getClip(); // Save current clipping region
    // Create a shape to use as the new clipping region.
    // Begin with an ellipse
    Area clip = new Area(new Ellipse2D.Float(0, 0, COVERWIDTH, COVERHEIGHT));
    // Intersect with a rectangle, truncating the ellipse.
    clip.intersect(new Area(new Rectangle(5, 5, COVERWIDTH - 10, COVERHEIGHT - 10)));
    // Then subtract an ellipse from the bottom of the truncated ellipse.
    clip.subtract(new Area(new Ellipse2D.Float(COVERWIDTH / 2 - 40, COVERHEIGHT - 20, 80, 40)));
    // Use the resulting shape as the new clipping region
    g.clip(clip);
    // Then draw the image through this clipping region
    g.drawImage(cover, 0, 0, this);
    // Restore the old clipping region so we can label the effect
    g.setClip(savedClip);
    g.drawString("Clipping", 0, COVERHEIGHT + 15);
}

From source file:org.jenkinsci.plugins.todos.TodosChartBuilder.java

/**
 * Build a trend chart from the provided data.
 * //from   w  ww. j  a  va2  s.  c o m
 * @param action
 *            the build action
 * @return the trend chart
 */
public static JFreeChart buildChart(TodosBuildAction action) {
    String strComments = Messages.Todos_ReportSummary_Comments();

    JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, strComments, buildDataset(action),
            PlotOrientation.VERTICAL, true, false, true);

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    TodosAreaRenderer renderer = new TodosAreaRenderer(action.getUrlName());
    plot.setRenderer(renderer);

    return chart;
}

From source file:org.jfree.chart.demo.DrawStringPanel.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D graphics2d = (Graphics2D) g;
    Dimension dimension = getSize();
    Insets insets = getInsets();/*  w w  w  .  j a v  a 2 s .c o m*/
    java.awt.geom.Rectangle2D.Double double1 = new java.awt.geom.Rectangle2D.Double(insets.left, insets.top,
            dimension.getWidth() - (double) insets.left - (double) insets.right,
            dimension.getHeight() - (double) insets.top - (double) insets.bottom);
    double d = double1.getCenterX();
    double d1 = double1.getCenterY();
    java.awt.geom.Line2D.Double double2 = new java.awt.geom.Line2D.Double(d - 2D, d1 + 2D, d + 2D, d1 - 2D);
    java.awt.geom.Line2D.Double double3 = new java.awt.geom.Line2D.Double(d - 2D, d1 - 2D, d + 2D, d1 + 2D);
    graphics2d.setPaint(Color.red);
    graphics2d.draw(double2);
    graphics2d.draw(double3);
    graphics2d.setFont(font);
    graphics2d.setPaint(Color.black);
    if (rotate)
        TextUtilities.drawRotatedString(text, graphics2d, (float) d, (float) d1, anchor, angle, rotationAnchor);
    else
        TextUtilities.drawAlignedString(text, graphics2d, (float) d, (float) d1, anchor);
}

From source file:org.jfree.chart.demo.XYAreaRenderer2Demo1.java

private static JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createXYAreaChart("XYAreaRenderer2Demo1", "Domain (X)", "Range (Y)",
            xydataset, PlotOrientation.VERTICAL, true, true, false);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setRenderer(new XYAreaRenderer2());
    xyplot.setForegroundAlpha(0.65F);// w w w .j  av  a2  s  .  c o m
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setTickMarkPaint(Color.black);
    valueaxis.setLowerMargin(0.0D);
    valueaxis.setUpperMargin(0.0D);
    ValueAxis valueaxis1 = xyplot.getRangeAxis();
    valueaxis1.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:EditorPaneExample4.java

public EditorPaneExample4() {
    super("JEditorPane Example 4");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from   ww w  .jav a  2 s  .co m*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);

    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;

    textField = new JTextField(32);
    panel.add(textField, c);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);

    getContentPane().add(panel, "South");

    // Change page based on text field
    textField.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String url = textField.getText();

            try {
                // Check if the new page and the old
                // page are the same.
                URL newURL = new URL(url);
                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(newURL)) {
                    return;
                }

                // Try to display the page
                textField.setEnabled(false); // Disable input
                textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);
                pane.setPage(url);

                loadedType.setText(pane.getContentType());
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url },
                        "File Open Error", JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                textField.setEnabled(true);
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadingState.setText("Page loaded.");
                textField.setEnabled(true); // Allow entry of new URL
                setCursor(Cursor.getDefaultCursor());
            }
        }
    });
}

From source file:Main.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    CheckComboStore store = (CheckComboStore) value;
    checkBox.setText(store.id);//w  w  w . j ava 2 s.c  om
    checkBox.setSelected(((Boolean) store.state).booleanValue());
    checkBox.setBackground(isSelected ? Color.red : Color.white);
    checkBox.setForeground(isSelected ? Color.white : Color.black);
    return checkBox;
}