Example usage for java.awt Color RED

List of usage examples for java.awt Color RED

Introduction

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

Prototype

Color RED

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

Click Source Link

Document

The color red.

Usage

From source file:SineDraw.java

public void paintComponent(Graphics g) {
    super.paintComponent(g);
    int maxWidth = getWidth();
    double hstep = (double) maxWidth / (double) points;
    int maxHeight = getHeight();
    pts = new int[points];
    for (int i = 0; i < points; i++)
        pts[i] = (int) (sines[i] * maxHeight / 2 * .95 + maxHeight / 2);
    g.setColor(Color.RED);
    for (int i = 1; i < points; i++) {
        int x1 = (int) ((i - 1) * hstep);
        int x2 = (int) (i * hstep);
        int y1 = pts[i - 1];
        int y2 = pts[i];
        g.drawLine(x1, y1, x2, y2);//w w  w .j av a2 s.com
    }
}

From source file:TexturedText.java

private BufferedImage getTextureImage() {
    // Create the test image.
    int size = 8;
    BufferedImage bi = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = bi.createGraphics();
    g2.setPaint(Color.red);
    g2.fillRect(0, 0, size / 2, size / 2);
    g2.setPaint(Color.yellow);/*from   ww  w .  j a  v a 2  s.c  o  m*/
    g2.fillRect(size / 2, 0, size, size / 2);
    g2.setPaint(Color.green);
    g2.fillRect(0, size / 2, size / 2, size);
    g2.setPaint(Color.blue);
    g2.fillRect(size / 2, size / 2, size, size);
    return bi;
}

From source file:MainClass.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    String s = "www.java2s.com";
    Dimension d = getSize();/*from   w w  w.  java2s.c  o  m*/

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    Font serifFont = new Font("Serif", Font.PLAIN, 48);
    Font sansSerifFont = new Font("Monospaced", Font.PLAIN, 48);

    AttributedString as = new AttributedString(s);
    as.addAttribute(TextAttribute.FONT, serifFont);
    as.addAttribute(TextAttribute.FONT, sansSerifFont, 2, 5);
    as.addAttribute(TextAttribute.FOREGROUND, Color.red, 2, 5);

    g2.drawString(as.getIterator(), 40, 80);

}

From source file:LazySample.java

public void paintIcon(Component c, Graphics g, int x, int y) {
    g.setColor(Color.RED);
    g.fillRect(1, 1, 20, 20);
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsUIUtil.java

public static ChartPanel buildGapChartPanel(final Instances dataSet, final int dateIdx, final Attribute attr,
        final int gapsize, final int position) throws Exception {
    Instances filteredDs = WekaDataProcessingUtil.buildFilteredByAttributesDataSet(dataSet,
            new int[] { attr.index(), dateIdx });
    filteredDs = WekaDataProcessingUtil.buildFilteredDataSet(filteredDs, 0, filteredDs.numAttributes() - 1,
            Math.max(0, position - GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize),
            Math.min(position + gapsize + GapsUtil.VALUES_BEFORE_AND_AFTER_RATIO * gapsize,
                    filteredDs.numInstances() - 1));

    final ChartPanel cp = TimeSeriesChartUtil.buildChartPanelForAllAttributes(filteredDs, false,
            WekaDataStatsUtil.getFirstDateAttributeIdx(filteredDs), null);

    final XYPlot xyp = (XYPlot) cp.getChart().getPlot();
    xyp.getDomainAxis().setLabel("");
    xyp.getRangeAxis().setLabel("");

    final Marker gapBeginMarker = new ValueMarker(dataSet.instance(Math.max(0, position - 1)).value(dateIdx));
    gapBeginMarker.setPaint(Color.RED);
    gapBeginMarker.setLabel("Gap begin");
    gapBeginMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
    gapBeginMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
    cp.getChart().getXYPlot().addDomainMarker(gapBeginMarker);

    final Marker gapEndMarker = new ValueMarker(
            dataSet.instance(Math.min(dataSet.numInstances() - 1, position + gapsize)).value(dateIdx));
    gapEndMarker.setPaint(Color.RED);
    gapEndMarker.setLabel("Gap end");
    gapEndMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    gapEndMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT);
    cp.getChart().getXYPlot().addDomainMarker(gapEndMarker);

    addExportPopupMenu(filteredDs, cp);/*from w  w w. j a v a2  s  .  c o  m*/

    return cp;
}

From source file:ExtendedParagraphExample.java

public static void createDocumentStyles(StyleContext sc) {
    Style defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE);

    // Create and add the main document style
    Style mainStyle = sc.addStyle(mainStyleName, defaultStyle);
    StyleConstants.setLeftIndent(mainStyle, 16);
    StyleConstants.setRightIndent(mainStyle, 16);
    StyleConstants.setFirstLineIndent(mainStyle, 16);
    StyleConstants.setFontFamily(mainStyle, "serif");
    StyleConstants.setFontSize(mainStyle, 12);

    // Create and add the constant width style
    Style cwStyle = sc.addStyle(charStyleName, null);
    StyleConstants.setFontFamily(cwStyle, "monospaced");
    StyleConstants.setForeground(cwStyle, Color.white);

    // Create and add the heading style
    Style heading2Style = sc.addStyle(heading2StyleName, null);
    StyleConstants.setForeground(heading2Style, Color.red);
    StyleConstants.setFontSize(heading2Style, 16);
    StyleConstants.setFontFamily(heading2Style, "serif");
    StyleConstants.setBold(heading2Style, true);
    StyleConstants.setLeftIndent(heading2Style, 8);
    StyleConstants.setFirstLineIndent(heading2Style, 0);

    // Create and add the extended para styles
    Style paraStyle = sc.addStyle(paraStyleName, null);
    Color bgColor = Color.gray;
    ExtendedStyleConstants.setParagraphBackground(paraStyle, bgColor);
    ExtendedStyleConstants.setParagraphBorder(paraStyle,
            BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
                    BorderFactory.createCompoundBorder(
                            BorderFactory.createEtchedBorder(bgColor.brighter(), bgColor.darker()),
                            BorderFactory.createEmptyBorder(4, 4, 4, 4))));
}

From source file:gov.nih.nci.caintegrator.ui.graphing.test.KaplanMeierGraphTester.java

public KaplanMeierGraphTester(String title) {
    super(title);
    Collection<KaplanMeierPlotPointSeriesSet> sets = new ArrayList<KaplanMeierPlotPointSeriesSet>();
    KaplanMeierPlotPointSeriesSet set1 = createKMPlotPointSeriesSet("Up Regulated", 10, .15);
    set1.setColor(Color.BLUE);//from w w w.  j  av a 2  s  . c  om
    sets.add(set1);

    KaplanMeierPlotPointSeriesSet set2 = createKMPlotPointSeriesSet("Down Regulated", 15, .25);
    set2.setColor(Color.RED);
    sets.add(set2);

    KaplanMeierPlotPointSeriesSet set3 = createKMPlotPointSeriesSet("Intermediate", 18, .07);
    set3.setColor(Color.GREEN);
    sets.add(set3);

    KaplanMeierPlot kmPlot = new KaplanMeierPlot(sets);
    JFreeChart chart = kmPlot.getKmChart();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(800, 600));
    setContentPane(chartPanel);
}

From source file:Main.java

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    g.setColor(Color.RED);
    g.fillOval(x, y - radius, radius * 2, radius * 2);
}

From source file:Test.java

License:asdf

public ApplicationWindow() {
    this.setSize(300, 300);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.add(new JButton("asdf"));
    final Polygon myShape = getPolygon();
    this.addComponentListener(new ComponentAdapter() {
        @Override/*from  w w w.  j  a v a 2s  . c o m*/
        public void componentResized(ComponentEvent e) {
            setShape(myShape);
            ((JFrame) e.getSource()).setForeground(Color.red);
            ((JFrame) e.getSource()).setBackground(Color.red);
        }
    });

    this.setUndecorated(true);
}

From source file:democsv.XYLineChart_AWT.java

public XYLineChart_AWT(String applicationTitle, String chartTitle) {
    super(applicationTitle);
    JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(xylineChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    final XYPlot plot = xylineChart.getXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.GREEN);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesStroke(0, new BasicStroke(4.0f));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f));
    renderer.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setRenderer(renderer);//from   w w w. j  a v a  2  s .c o  m
    setContentPane(chartPanel);
}