List of usage examples for java.awt Color RED
Color RED
To view the source code for java.awt Color RED.
Click Source Link
From source file:Main.java
public TextPaneAttributes() { JTextPane textPane = new JTextPane(); StyledDocument doc = textPane.getStyledDocument(); MutableAttributeSet standard = new SimpleAttributeSet(); StyleConstants.setAlignment(standard, StyleConstants.ALIGN_CENTER); doc.setParagraphAttributes(0, 0, standard, true); MutableAttributeSet keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.red); StyleConstants.setItalic(keyWord, true); textPane.setText("this is a test. \nthis is a four."); doc.setCharacterAttributes(0, 3, keyWord, false); doc.setCharacterAttributes(19, 4, keyWord, false); try {//www . j a v a 2s . c o m doc.insertString(0, "Start of text\n", null); doc.insertString(doc.getLength(), "End of text\n", keyWord); } catch (Exception e) { } MutableAttributeSet selWord = new SimpleAttributeSet(); StyleConstants.setForeground(selWord, Color.RED); StyleConstants.setItalic(selWord, true); JScrollPane scrollPane = new JScrollPane(textPane); scrollPane.setPreferredSize(new Dimension(200, 200)); add(scrollPane); JButton toggleButton = new JButton("Find 'four'"); toggleButton.addActionListener(e -> { int index = textPane.getText().indexOf("four"); StyledDocument doc1 = textPane.getStyledDocument(); doc1.setCharacterAttributes(index, 4, selWord, false); }); add(toggleButton, BorderLayout.SOUTH); }
From source file:BouncingCircle.java
/** This method simply draws the circle at its current position */ public void paint(Graphics g) { g.setColor(Color.red); g.fillOval(x - r, y - r, r * 2, r * 2); }
From source file:BallRoom.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); Shape ball = new Ellipse2D.Float(i++, i++, 5, 5); g2.setColor(Color.RED); g2.fill(ball);/*from w w w . ja va 2 s . c o m*/ }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setPaint(Color.black);//from w w w. ja v a 2 s .c o m g2.draw(shape); AffineTransform at = AffineTransform.getTranslateInstance(75, 75); g2.transform(at); g2.setPaint(Color.red); g2.draw(shape); }
From source file:org.jfree.chart.demo.MultipleAxisDemo4.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset("March 2007", 100D, new Day(1, 3, 2007), 31); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Multiple Axis Demo 4", "Date", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.red); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setTickLabelPaint(Color.red); DateAxis dateaxis1 = new DateAxis("Date"); dateaxis1.setDateFormatOverride(new SimpleDateFormat("d-MMM-yyyy")); xyplot.setDomainAxis(1, dateaxis1);/*from www .j a v a2 s .c om*/ xyplot.setDomainAxisLocation(1, AxisLocation.TOP_OR_LEFT); NumberAxis numberaxis1 = new NumberAxis("Value"); numberaxis1.setAutoRangeIncludesZero(false); numberaxis1.setTickLabelPaint(Color.blue); xyplot.setRangeAxis(1, numberaxis1); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); XYDataset xydataset1 = createDataset("July 2007", 1000D, new Day(1, 7, 2007), 31); xyplot.setDataset(1, xydataset1); xyplot.mapDatasetToDomainAxis(1, 1); xyplot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.blue); xyplot.setRenderer(1, xylineandshaperenderer); return jfreechart; }
From source file:com.cablelabs.gui.scripts.visualizer.TransitionPainter.java
@Override public Paint transform(Transition t) { // Transitions to an end state are red if (t.getTo().equals("END")) return Color.RED; return Color.BLACK; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.RED); g2d.fill(poly);/*from w ww.j a v a 2s. c o m*/ g2d.setColor(Color.GREEN); g2d.translate(50, 100); g2d.fill(triangleShape); g2d.dispose(); }
From source file:UserInterface.FarmerRole.ThermometerDemo.java
public ThermometerDemo(double value, String type) { this.setLayout(new GridLayout()); DefaultValueDataset dataset = new DefaultValueDataset(value); if (type.equals("high")) { ThermometerPlot plot = new ThermometerPlot(dataset); plot.setSubrangePaint(0, Color.green.darker()); plot.setSubrangePaint(1, Color.ORANGE); plot.setSubrangePaint(2, Color.RED.darker()); plot.setSubrangeInfo(0, 10, 28, 30, 60); JFreeChart chart = new JFreeChart("Cold Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true); this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true)); } else if (type.equals("medium")) { ThermometerPlot plot = new ThermometerPlot(dataset); plot.setSubrangePaint(0, Color.green.darker()); plot.setSubrangePaint(1, Color.ORANGE); plot.setSubrangePaint(2, Color.RED.darker()); plot.setSubrangeInfo(0, 12, 14, 30, 60); JFreeChart chart = new JFreeChart("Medium Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true); this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true)); } else {/*from ww w . j ava 2 s . co m*/ ThermometerPlot plot = new ThermometerPlot(dataset); plot.setSubrangePaint(0, Color.green.darker()); plot.setSubrangePaint(1, Color.YELLOW); plot.setSubrangePaint(2, Color.RED.darker()); plot.setSubrangeInfo(0, 20, 35, 46, 60); JFreeChart chart = new JFreeChart("Warm Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true); this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true)); } }
From source file:jamel.gui.charts.sectorFinal.Prices.java
/** * Returns the chart./* w w w. j av a2 s .c o m*/ * @return the chart. */ private static JFreeChart newChart() { final TimeChart chart = new TimeChart("Final Good Prices", "Value", Circuit.getCircuit().getTimeSeries().get(Labels.PRICE_FINAL_MIN), Circuit.getCircuit().getTimeSeries().get(Labels.PRICE_FINAL_MAX), Circuit.getCircuit().getTimeSeries().get(Labels.PRICE_FINAL_MEDIAN)); chart.setXYDifferenceRenderer(0, JamelColor.ULTRA_TRANSPARENT_RED, JamelColor.ULTRA_TRANSPARENT_RED); chart.setColors(0, JamelColor.VERY_LIGHT_RED, JamelColor.VERY_LIGHT_RED, Color.RED); chart.addLineLegendItem("Median Price", Color.RED); chart.addLegendItem("Min-Max Prices", JamelColor.VERY_LIGHT_RED); return chart; }
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.RED); g2d.drawLine(0, 0, getWidth(), getHeight()); g2d.drawLine(getWidth(), 0, 0, getHeight()); g2d.dispose();/*from w ww . j a va 2 s.c om*/ }