Example usage for java.awt Color gray

List of usage examples for java.awt Color gray

Introduction

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

Prototype

Color gray

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

Click Source Link

Document

The color gray.

Usage

From source file:ca.sqlpower.wabit.swingui.report.selectors.FancyDateSelectorField.java

private void refreshEverything() {

    if (getDate() == null) {
        setDate((Date) selector.getDefaultValue());
    }//w  w  w.  j a  v  a 2 s.  co m

    if (ObjectUtils.equals(getDate(), selector.getDefaultValue())) {
        selector.setSelectedValue(null);
        setForeground(Color.GRAY);
        setFont(getFont().deriveFont(Font.ITALIC));
    } else {
        selector.setSelectedValue(getDate());
        setForeground(Color.BLACK);
        setFont(getFont().deriveFont(Font.PLAIN));
    }
    SwingUtilities.invokeLater(refreshRoutine);
}

From source file:ColorChooserMenu.java

public ColorMenu(String name) {
    super(name);//from  w w  w.ja  va 2 s.  com
    unselectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, getBackground()),
            new BevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
    selectedBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.red),
            new MatteBorder(1, 1, 1, 1, getBackground()));
    activeBorder = new CompoundBorder(new MatteBorder(1, 1, 1, 1, Color.blue),
            new MatteBorder(1, 1, 1, 1, getBackground()));

    JPanel p = new JPanel();
    p.setBorder(new EmptyBorder(5, 5, 5, 5));
    p.setLayout(new GridLayout(8, 8));
    paneTable = new Hashtable();

    int[] values = new int[] { 0, 128, 192, 255 };

    for (int r = 0; r < values.length; r++) {
        for (int g = 0; g < values.length; g++) {
            for (int b = 0; b < values.length; b++) {
                Color c = new Color(values[r], values[g], values[b]);
                ColorPane pn = new ColorPane(c);
                p.add(pn);
                paneTable.put(c, pn);
            }
        }
    }
    add(p);
}

From source file:temp1.RealTimeChart.java

public static JFreeChart createChart(String chartContent, String title, String yaxisName) {
    thread1 = new Thread();
    timeseries1 = new TimeSeries(chartContent, Millisecond.class);
    timeseries2 = new TimeSeries(chartContent, Millisecond.class);
    timeseries3 = new TimeSeries(chartContent, Millisecond.class);
    timeseries4 = new TimeSeries(chartContent, Millisecond.class);

    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries1);
    TimeSeriesCollection timeseriescollection1 = new TimeSeriesCollection(timeseries2);
    TimeSeriesCollection timeseriescollection2 = new TimeSeriesCollection(timeseries3);
    TimeSeriesCollection timeseriescollection3 = new TimeSeriesCollection(timeseries4);

    jfreechart = ChartFactory.createTimeSeriesChart("", "", "", timeseriescollection, false, false, false);

    final XYPlot xyplot = jfreechart.getXYPlot();
    xyplot.setOutlinePaint(Color.magenta);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.gray);
    xyplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setAutoRange(true);//  w  ww.j a v a  2 s. c om
    valueaxis.setFixedAutoRange(20000D);
    //Value
    valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(800D, 3300D);
    xyplot.setDataset(0, timeseriescollection);
    xyplot.setDataset(1, timeseriescollection1);
    xyplot.setDataset(2, timeseriescollection2);
    xyplot.setDataset(3, timeseriescollection3);
    XYLineAndShapeRenderer xylineandshaperenderer0 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer xylineandshaperenderer2 = new XYLineAndShapeRenderer();
    XYLineAndShapeRenderer xylineandshaperenderer3 = new XYLineAndShapeRenderer();
    xylineandshaperenderer0.setBaseShapesVisible(false);
    xylineandshaperenderer1.setBaseShapesVisible(false);
    xylineandshaperenderer2.setBaseShapesVisible(false);
    xylineandshaperenderer3.setBaseShapesVisible(false);
    xylineandshaperenderer0.setSeriesPaint(0, Color.RED);
    xylineandshaperenderer1.setSeriesPaint(0, Color.cyan);
    xylineandshaperenderer2.setSeriesPaint(0, Color.yellow);
    xylineandshaperenderer3.setSeriesPaint(0, Color.blue);
    xyplot.setRenderer(0, xylineandshaperenderer0);
    xyplot.setRenderer(1, xylineandshaperenderer1);
    xyplot.setRenderer(2, xylineandshaperenderer2);
    xyplot.setRenderer(3, xylineandshaperenderer3);
    //xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(0.5F, 1, 1, 5F, new float[] { 5F, 10F }, 0.0F));
    return jfreechart;
}

From source file:bayesGame.ui.transformers.BayesNodeProbabilityToGridTransformer.java

@Override
public Icon transform(BayesNode node) {
    Fraction probability = node.getProbability();
    double cells = probability.percentageValue();

    Image grid;/* ww  w. j  av a  2s  . c o m*/
    Color trueColor = BayesGame.trueColor;
    Color falseColor = BayesGame.falseColor;

    boolean hiddennode = node.hasProperty("hidden");
    boolean targetnode = node.hasProperty("target");

    if (node.hasProperty("misguessed")) {
        trueColor = Color.GRAY;
        falseColor = Color.BLACK;
    }

    // TODO: indicate target nodes somehow

    if (node.cptName == null) {
        node.cptName = "";
    }

    if (node.cptName.equals("DetIS")) {
        grid = new IsNodePainter().paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize);
    } else if (node.cptName.equals("DetNOT")) {
        grid = new NotNodePainter().paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize);
    } else if (node.cptName.equals("Prior")) {
        grid = PriorPainter.paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize);
    } else if (node.cptName.equals("DetOR")) {
        List<Object> parentTypeList = net.getParents(node.type);
        Fraction parentNode1Probability = net.getProbability(parentTypeList.get(0));
        Fraction parentNode2Probability = net.getProbability(parentTypeList.get(1));
        grid = OrNodePainter.paintPercentage(trueColor, falseColor, (int) (rows * squaresize * 3.5), squaresize,
                node, parentNode1Probability, parentNode2Probability);
    } else if (node.cptName.equals("DetAND")) {
        List<Object> parentTypeList = net.getParents(node.type);
        Fraction parentNode1Probability = net.getProbability(parentTypeList.get(0));
        Fraction parentNode2Probability = net.getProbability(parentTypeList.get(1));
        grid = AndNodePainter.paintPercentage(trueColor, falseColor, (int) (rows * squaresize * 3.5),
                squaresize, node, parentNode1Probability, parentNode2Probability);
    } else if (node.cptName.equals("DetNOTAnd")) {
        grid = DetNOTAnd.paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize, node);
    } else if (node.cptName.equals("Bayes")) {
        List<Object> parentTypeList = net.getParents(node.type);
        Fraction parentNodeProbability = net.getProbability(parentTypeList.get(0));
        grid = BayesPainter.paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize, node,
                parentNodeProbability);
    }

    else {
        grid = GridPainter.paintPercentage(cells, trueColor, falseColor, rows, columns, squaresize);
    }

    if (hiddennode) {
        grid = NodePainter.getBorders((BufferedImage) grid, Color.BLACK);
    } else if (!node.isObserved()) {
        grid = NodePainter.getBorders((BufferedImage) grid, Color.GRAY);
    }

    int x_size = grid.getHeight(null);
    double size_multiplier = 0.7;
    int new_x_size = (int) (x_size * size_multiplier);

    ImageIcon icon = new ImageIcon(grid.getScaledInstance(-1, new_x_size, Image.SCALE_SMOOTH));

    // ImageIcon icon = new ImageIcon(grid);

    return icon;
}

From source file:RotationAboutCenter.java

protected void paintComponent(Graphics g) {
    Graphics2D g2d;/*from w  ww.ja  v a2  s .c o  m*/
    g2d = (Graphics2D) g.create();

    // Erase background to white
    g2d.setColor(Color.WHITE);
    g2d.fillRect(0, 0, getWidth(), getHeight());

    // base rectangle
    g2d.setColor(Color.GRAY.brighter());
    g2d.fillRect(50, 50, 50, 50);

    // rotated 45 degrees around origin
    g2d.rotate(Math.toRadians(45));
    g2d.setColor(Color.GRAY.darker());
    g2d.fillRect(50, 50, 50, 50);

    // rotated 45 degrees about center of rect
    g2d = (Graphics2D) g.create();
    g2d.rotate(Math.toRadians(45), 75, 75);
    g2d.setColor(Color.BLACK);
    g2d.fillRect(50, 50, 50, 50);

    // done with g2d, dispose it
    g2d.dispose();
}

From source file:at.tuwien.ifs.commons.gui.controls.MultiOptionToggleButton.java

public MultiOptionToggleButton(final ImageIcon[] icons, final String[] buttonTexts, final String tooltip,
        final MultiOptionToggleListener listener) {
    super(icons[0]);
    this.setToolTipText(tooltip);
    this.addActionListener(new ActionListener() {
        @Override/*w ww. java 2s  .c o  m*/
        public void actionPerformed(ActionEvent e) {
            menu.show(MultiOptionToggleButton.this, 0, MultiOptionToggleButton.this.getHeight());

            // highlight current selection
            final Component[] components = menu.getComponents();
            for (Component c : components) {
                c.setBackground(null);
            }
            menu.getComponent(selectedIndex).setBackground(Color.GRAY);
        }
    });

    for (int i = 0; i < buttonTexts.length; i++) {
        JMenuItem jMenuItem = new JMenuItem(buttonTexts[i], icons[i]);
        jMenuItem.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                listener.performAction(e.getActionCommand());
                selectedIndex = ArrayUtils.indexOf(buttonTexts, e.getActionCommand());
                setIcon(icons[selectedIndex]);
            }
        });
        menu.add(jMenuItem);
    }

    JMenuBar menuBar = new JMenuBar();
    menuBar.setBorderPainted(false);
    menuBar.add(menu);
}

From source file:de.hs.mannheim.modUro.diagram.JCellCountDiagram.java

protected JFreeChart createChart(XYDataset dataset, String name) {
    String title = name;//  ww  w. ja v a 2s.c  o  m

    JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title
            "t", // x-axis label
            "n", // y-axis label
            dataset);

    String fontName = "Palatino";
    xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));

    XYPlot plot = (XYPlot) xyLineChart.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    plot.getDomainAxis().setLowerMargin(0.0);
    plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.getRangeAxis().setLowerMargin(0.0);
    // plot.getRangeAxis().setRange(0.0, 1.01);
    plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
    plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.gray);
    xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
    xyLineChart.getLegend().setFrame(BlockBorder.NONE);
    xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
    XYItemRenderer r = plot.getRenderer();
    // set the default stroke for all series
    int i = 0;
    for (String celltype : getTimeSeries().getDataSeriesNames()) {
        r.setSeriesPaint(i, CellTypeColor.getColor(celltype));
        i++;
    }
    r.setSeriesPaint(i, Color.BLACK);
    return xyLineChart;
}

From source file:com.intuit.tank.tools.debugger.VariableDialog.java

public VariableDialog(AgentDebuggerFrame f, Map<String, String> variables) {
    super(f, true);
    this.f = f;/*from   w w  w .ja  v  a 2 s  . c o  m*/
    setLayout(new BorderLayout());
    setTitle("View Edit Project Variables");
    DefaultTableModel model = new DefaultTableModel();
    model.addColumn("Variable Name");
    model.addColumn("Variable Value");
    List<String> keys = new ArrayList<String>(variables.keySet());
    Collections.sort(keys);
    for (String key : keys) {
        Object[] data = new Object[2];
        data[0] = key;
        data[1] = variables.get(key);
        model.addRow(data);
    }
    table = new JTable(model);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.getSelectionModel().addListSelectionListener(this);
    table.setGridColor(Color.GRAY);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    table.setShowGrid(true);
    table.getTableHeader().setReorderingAllowed(false);

    JScrollPane sp = new JScrollPane(table);
    JPanel panel = new JPanel(new BorderLayout());

    panel.add(table.getTableHeader(), BorderLayout.NORTH);
    panel.add(sp, BorderLayout.CENTER);

    add(panel, BorderLayout.CENTER);
    add(createButtonPanel(), BorderLayout.SOUTH);
    setSize(new Dimension(800, 600));
    setBounds(new Rectangle(getSize()));
    setPreferredSize(getSize());
    WindowUtil.centerOnParent(this);
}

From source file:it.alus.GPSreceiver.instruments.Compass.java

public Compass(boolean trueTrack) {
    super(null);/*from  ww w  .  j ava 2s.com*/
    isTrueTrack = trueTrack;
    dataset = new DefaultValueDataset(0.0);
    DialPlot plot = new DialPlot();
    //Image background=Toolkit.getDefaultToolkit().getImage(getClass().getResource("heading.png"));
    //plot.setBackgroundImage(background);
    plot.setView(0.0, 0.0, 1.0, 1.0);
    plot.setDataset(0, dataset);
    StandardDialFrame dialFrame = new StandardDialFrame();
    dialFrame.setBackgroundPaint(Color.lightGray);
    dialFrame.setForegroundPaint(Color.gray);
    N = new DialTextAnnotation("N");
    N.setFont(new Font("Arial", 1, 32));
    N.setPaint(Color.white);
    N.setAnchor(TextAnchor.CENTER);
    plot.addLayer(N);
    S = new DialTextAnnotation("S");
    S.setFont(new Font("Arial", 1, 32));
    S.setPaint(Color.white);
    S.setAnchor(TextAnchor.CENTER);
    plot.addLayer(S);
    W = new DialTextAnnotation("W");
    W.setFont(new Font("Arial", 1, 32));
    W.setPaint(Color.white);
    W.setAnchor(TextAnchor.CENTER);
    plot.addLayer(W);
    E = new DialTextAnnotation("E");
    E.setFont(new Font("Arial", 1, 32));
    E.setPaint(Color.white);
    E.setAnchor(TextAnchor.CENTER);
    plot.addLayer(E);
    repositionDirectionsLabels(90);
    DialValueIndicator valueindicator = new DialValueIndicator(0);
    plot.addLayer(valueindicator);
    plot.setDialFrame(dialFrame);
    realScale = new StandardDialScale(0, 360, 90, -360, 30, 6);
    realScale.setVisible(false);
    realScale.setFirstTickLabelVisible(false);
    plot.addScale(0, realScale);
    dispScale = new StandardDialScale(0, 36, 90, -360, 3, 15);
    dispScale.setFirstTickLabelVisible(false);
    dispScale.setMajorTickPaint(Color.white);
    dispScale.setMinorTickPaint(Color.lightGray);
    dispScale.setFirstTickLabelVisible(true);
    dispScale.setTickRadius(0.88);
    dispScale.setTickLabelOffset(0.15);
    NumberFormat formatter = new DecimalFormat("#");
    dispScale.setTickLabelFormatter(formatter);
    dispScale.setTickLabelFont(new Font("Arial", Font.BOLD, 22));
    dispScale.setTickLabelPaint(Color.white);
    plot.addScale(1, dispScale);
    plot.setBackground(new DialBackground(Color.black));
    Pointer needle = new Pointer(0);
    needle.setFillPaint(Color.red);
    needle.setRadius(0.8);
    plot.addLayer(needle);
    plot.mapDatasetToScale(1, 1);
    DialCap cap = new DialCap();
    cap.setRadius(0.05);
    cap.setFillPaint(Color.gray);
    plot.setCap(cap);
    jChart = new JFreeChart(plot);
    //jChart.setBackgroundImage(background);
    super.setChart(jChart);
    super.setPreferredSize(new Dimension(400, 400));
}

From source file:application.BrokersMouseListener.java

@Override
public void graphClicked(Object arg0, MouseEvent arg1) {

    //Reset the selected variable for all the broker
    ListIterator<Broker> it = state.getBrokersList();
    while (it.hasNext()) {
        it.next().resetSelected();/*from  w  w w. j  a v a2 s .co  m*/
    }

    Broker broker = (Broker) arg0;

    //SET the selected variable for THE SPECIFIC broker
    broker.setSelected();
    Transformer<Broker, Paint> vertexPaint = new Transformer<Broker, Paint>() {
        public Paint transform(Broker b) {
            if (b.selected()) {
                return Color.GREEN;
            }
            return Color.GRAY;
        }
    };

    //Reset the selected variable for all the link
    it = state.getBrokersList();
    while (it.hasNext()) {
        Broker b = it.next();
        ListIterator<Interface> intit = b.getInterfaces();
        while (intit.hasNext()) {
            Interface ix = intit.next();
            ix.getLink().resetSelected();
        }
    }

    //SET the selected variable for THE SPECIFIC links
    it = state.getBrokersList();
    while (it.hasNext()) {
        Broker b = it.next();
        ListIterator<Interface> intit = b.getInterfaces();
        if (b.equals(broker)) {
            while (intit.hasNext()) {
                Interface ix = intit.next();
                ix.getLink().setSelected();
            }
        } else {
            while (intit.hasNext()) {
                Interface ix = intit.next();
                ix.getLink().setSelectedBcastFunction(state.getBrokerPosition(broker));
            }
        }
    }

    Transformer<Link, Stroke> edgeStrokeTransformer = new Transformer<Link, Stroke>() {
        public Stroke transform(Link link) {

            if (link.selected()) {
                final Stroke edgeStroke = new BasicStroke(2);
                return edgeStroke;
            } else {
                float[] dot = { 1.0f, 3.0f };
                final Stroke edgeStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND,
                        1.0f, dot, 0f);
                return edgeStroke;
            }
        }
    };

    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);

    //((FRLayout)layout).initialize();
    //((FRLayout)layout).step();
    vv.repaint();
}