List of usage examples for java.awt Color YELLOW
Color YELLOW
To view the source code for java.awt Color YELLOW.
Click Source Link
From source file:gsn.vsensor.DemoVSensor.java
public void dataAvailable(String inputStreamName, StreamElement data) { if (inputStreamName.equalsIgnoreCase("SSTREAM")) { String action = (String) data.getData("STATUS"); /**/*from www . j av a 2 s. c om*/ * */ String moteId = (String) data.getData("ID"); if (moteId.toLowerCase().indexOf("mica") < 0) return; if (action.toLowerCase().indexOf("add") >= 0) counter++; if (action.toLowerCase().indexOf("remove") >= 0) counter--; } if (inputStreamName.equalsIgnoreCase("CSTREAM")) { BufferedImage bufferedImage = null; outputStream.reset(); byte[] rawData = (byte[]) data.getData("IMAGE"); input = new ByteArrayInputStream(rawData); try { bufferedImage = ImageIO.read(input); } catch (IOException e) { logger.error(e.getMessage(), e); } Graphics2D graphics = (Graphics2D) bufferedImage.getGraphics(); int size = 30; int locX = 0; int locY = 0; if (counter < 0) counter = 0; switch (counter) { case 0: graphics.setColor(Color.RED); break; case 1: graphics.setColor(Color.ORANGE); break; case 2: graphics.setColor(Color.YELLOW); break; case 3: graphics.setColor(Color.GREEN); break; default: logger.warn( new StringBuilder().append("Shouldn't happen.>").append(counter).append("<").toString()); } graphics.fillOval(locX, locY, size, size); try { ImageIO.write(bufferedImage, "jpeg", outputStream); outputStream.close(); } catch (Exception e) { logger.error(e.getMessage(), e); } StreamElement outputSE = new StreamElement(OUTPUT_FIELDS, OUTPUT_TYPES, new Serializable[] { outputStream.toByteArray() }, data.getTimeStamp()); dataProduced(outputSE); } logger.info( new StringBuilder().append("Data received under the name: ").append(inputStreamName).toString()); }
From source file:org.gvsig.gui.beans.graphic.GraphicChartPanel.java
/** * Creates a chart.//from w w w .j a va 2 s . com * @param dataset the dataset. * @return A chart. */ private void createChart() { chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, true); // Definir la lista de colores XYPlot plot = chart.getXYPlot(); plot.getRenderer().setSeriesPaint(0, Color.red); plot.getRenderer().setSeriesPaint(1, Color.green); plot.getRenderer().setSeriesPaint(2, Color.blue); plot.getRenderer().setSeriesPaint(3, Color.cyan); plot.getRenderer().setSeriesPaint(4, Color.black); plot.getRenderer().setSeriesPaint(5, Color.darkGray); plot.getRenderer().setSeriesPaint(6, Color.gray); plot.getRenderer().setSeriesPaint(7, Color.magenta); plot.getRenderer().setSeriesPaint(8, Color.yellow); plot.getRenderer().setSeriesPaint(9, Color.orange); Image img = new ImageIcon(getClass().getResource("images/splash.png")).getImage(); plot.setBackgroundPaint(null); plot.setBackgroundImageAlpha(0.18f); plot.setBackgroundImage(img); }
From source file:org.jfree.chart.demo.NormalDistributionDemo2.java
public static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("Normal Distribution Demo 2", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainZeroBaselineVisible(true); xyplot.setRangeZeroBaselineVisible(true); xyplot.setDomainPannable(true);// www . j a v a2 s. c om xyplot.setRangePannable(true); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setDrawSeriesLineAsPath(true); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1.5F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(2, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 6F, 4F, 3F, 3F }, 0.0F)); xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2.0F, 1, 1, 1.0F, new float[] { 4F, 4F }, 0.0F)); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(" = -2.0, \262 = 0.5", -2D, 0.56399999999999995D, 3.9269908169872414D); xypointerannotation.setLabelOffset(4D); xypointerannotation.setTextAnchor(TextAnchor.BOTTOM_RIGHT); xypointerannotation.setBackgroundPaint(Color.yellow); xyplot.addAnnotation(xypointerannotation); XYPointerAnnotation xypointerannotation1 = new XYPointerAnnotation(" = 0.0, \262 = 0.2", 0.22500000000000001D, 0.80000000000000004D, 0.0D); xypointerannotation1.setLabelOffset(4D); xypointerannotation1.setTextAnchor(TextAnchor.CENTER_LEFT); xypointerannotation1.setBackgroundPaint(new Color(0, 0, 255, 63)); xyplot.addAnnotation(xypointerannotation1); XYPointerAnnotation xypointerannotation2 = new XYPointerAnnotation(" = 0.0, \262 = 1.0", 0.75D, 0.29999999999999999D, 5.497787143782138D); xypointerannotation2.setLabelOffset(4D); xypointerannotation2.setTextAnchor(TextAnchor.HALF_ASCENT_LEFT); xypointerannotation2.setBackgroundPaint(new Color(255, 0, 0, 63)); xyplot.addAnnotation(xypointerannotation2); XYPointerAnnotation xypointerannotation3 = new XYPointerAnnotation(" = 0.0, \262 = 5.0", 3D, 0.074999999999999997D, 4.7123889803846897D); xypointerannotation3.setLabelOffset(4D); xypointerannotation3.setTextAnchor(TextAnchor.BOTTOM_CENTER); xypointerannotation3.setBackgroundPaint(new Color(0, 255, 0, 63)); xyplot.addAnnotation(xypointerannotation3); return jfreechart; }
From source file:com.att.aro.ui.view.diagnostictab.plot.BurstPlot.java
public void populate(XYPlot plot, AROTraceData analysis) { if (analysis != null) { burstDataCollection.removeAllSeries(); Map<BurstCategory, XYIntervalSeries> seriesMap = new EnumMap<BurstCategory, XYIntervalSeries>( BurstCategory.class); final Map<BurstCategory, List<Burst>> burstMap = new HashMap<BurstCategory, List<Burst>>(); for (BurstCategory eventType : BurstCategory.values()) { XYIntervalSeries series = new XYIntervalSeries(eventType); seriesMap.put(eventType, series); burstDataCollection.addSeries(series); burstMap.put(eventType, new ArrayList<Burst>()); }/*from w w w . ja va2 s.c o m*/ final List<Burst> burstStates = analysis.getAnalyzerResult().getBurstcollectionAnalysisData() .getBurstCollection(); Iterator<Burst> iter = burstStates.iterator(); while (iter.hasNext()) { Burst currEvent = iter.next(); if (currEvent != null) { BurstCategory burstState = currEvent.getBurstCategory(); if (burstState != null) { seriesMap.get(burstState).add(currEvent.getBeginTime(), currEvent.getBeginTime(), currEvent.getEndTime(), 0.5, 0, 1); burstMap.get(burstState).add(currEvent); } } } Color myGreen = new Color(34, 177, 76); Color lightGreen = new Color(134, 232, 162); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_PROTOCOL), Color.blue); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.TCP_LOSS_OR_DUP), Color.black); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.USER_INPUT), myGreen); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SCREEN_ROTATION), lightGreen); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CLIENT_APP), Color.red); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.SERVER_NET_DELAY), Color.yellow); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.LONG), Color.gray); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.PERIODICAL), Color.magenta); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.CPU), Color.cyan); renderer.setSeriesPaint(burstDataCollection.indexOf(BurstCategory.UNKNOWN), Color.darkGray); // Assign ToolTip to renderer renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { BurstCategory eventType = (BurstCategory) burstDataCollection.getSeries(series).getKey(); Burst b; int size = burstMap.get(eventType).size(); if (size > item) { b = burstMap.get(eventType).get(item); } else { b = burstMap.get(eventType).get(size); } final String PREFIX = "BurstCategory."; return MessageFormat.format(ResourceBundleHelper.getMessageString(PREFIX + eventType.ordinal()), b.getPackets().size(), b.getBurstBytes(), b.getBurstThroughPut()); } }); } plot.setDataset(burstDataCollection); // return plot; }
From source file:DualAxisDemo4.java
/** * Creates a new demo instance.//from w ww . j av a2 s . c om * * @param title the frame title. */ public DualAxisDemo4(final String title) { super(title); final CategoryDataset dataset1 = createDataset1(); // create the chart... final JFreeChart chart = ChartFactory.createBarChart3D("Dual Axis Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset1, // data PlotOrientation.VERTICAL, true, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC)); // chart.getLegend().setAnchor(Legend.SOUTH); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); final CategoryItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.red); renderer1.setSeriesPaint(1, Color.yellow); renderer1.setSeriesPaint(2, Color.green); final CategoryDataset dataset2 = createDataset2(); final ValueAxis axis2 = new NumberAxis3D("Secondary"); plot.setRangeAxis(1, axis2); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); final CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); renderer2.setSeriesPaint(0, Color.blue); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:Transfer.java
public Transfer() { // Establish the GUI Container cp = new Box(BoxLayout.X_AXIS); setContentPane(cp);//from w ww . java 2 s . c o m JPanel firstPanel = new JPanel(); propertyComboBox = new JComboBox(); propertyComboBox.addItem("text"); propertyComboBox.addItem("font"); propertyComboBox.addItem("background"); propertyComboBox.addItem("foreground"); firstPanel.add(propertyComboBox); cp.add(firstPanel); cp.add(Box.createGlue()); tf = new JTextField("Hello"); tf.setForeground(Color.RED); tf.setDragEnabled(true); cp.add(tf); cp.add(Box.createGlue()); l = new JLabel("Hello"); l.setBackground(Color.YELLOW); cp.add(l); cp.add(Box.createGlue()); JSlider stryder = new JSlider(SwingConstants.VERTICAL); stryder.setMinimum(10); stryder.setValue(14); stryder.setMaximum(72); stryder.setMajorTickSpacing(10); stryder.setPaintTicks(true); cp.add(stryder); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500, 300); // Add Listeners and Converters setMyTransferHandlers((String) propertyComboBox.getSelectedItem()); // Mousing in the Label starts a Drag. MouseListener myDragListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { JComponent c = (JComponent) e.getSource(); TransferHandler handler = c.getTransferHandler(); handler.exportAsDrag(c, e, TransferHandler.COPY); } }; l.addMouseListener(myDragListener); // Selecting in the ComboBox makes that the property that is xfered. propertyComboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ce) { JComboBox bx = (JComboBox) ce.getSource(); String prop = (String) bx.getSelectedItem(); setMyTransferHandlers(prop); } }); // Typing a word and pressing enter in the TextField tries // to set that as the font name. tf.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { JTextField jtf = (JTextField) evt.getSource(); String fontName = jtf.getText(); Font font = new Font(fontName, Font.BOLD, 18); tf.setFont(font); } }); // Setting the Slider sets that font into the textfield. stryder.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent evt) { JSlider sl = (JSlider) evt.getSource(); Font oldf = tf.getFont(); Font newf = oldf.deriveFont((float) sl.getValue()); tf.setFont(newf); } }); }
From source file:ImageLabel.java
public void paint(Graphics g) { /*//from ww w .java 2 s. c om * Draw the image stretched to exactly cover the size of the drawing area. */ Dimension size = getSize(); g.drawImage(img, 0, 0, size.width, size.height, 0, 0, img.getWidth(null), img.getHeight(null), null); /* * Fill a rounded rectangle centered in the drawing area. Calculate the size * of the rectangle from the size of the text */ g.setFont(font); FontRenderContext frc = ((Graphics2D) g).getFontRenderContext(); Rectangle2D bounds = font.getStringBounds(text, frc); int wText = (int) bounds.getWidth(); int hText = (int) bounds.getHeight(); int rX = (size.width - wText) / 2; int rY = (size.height - hText) / 2; g.setColor(Color.yellow); g.fillRoundRect(rX, rY, wText, hText, hText / 2, hText / 2); /* * Draw text positioned in the rectangle. Since the rectangle is sized based * on the bounds of the String we can position it using those bounds. */ int xText = rX - (int) bounds.getX(); int yText = rY - (int) bounds.getY(); g.setColor(Color.black); g.setFont(font); g.drawString(text, xText, yText); }
From source file:sim.app.sugarscape.SugarscapeWithUIHigh.java
public void setupPortrayals() { // tell the portrayals what to // portray and how to portray them agentsPortrayal.setField(((Sugarscape) state).agents_grid); AgentPortrayal2D ap = new AgentPortrayal2D(Color.blue); agentsPortrayal.setPortrayalForNull(ap); agentsPortrayal.setPortrayalForAll(ap); /* does all cover null objects? */ scapePortrayal.setField(((Sugarscape) state).scape_grid); scapePortrayal.setPortrayalForAll(new sim.app.sugarscape.ScapePortrayal2D(Color.yellow)); pollutionPortrayal.setField(((Sugarscape) state).scape_grid); pollutionPortrayal.setPortrayalForAll(new sim.app.sugarscape.PollutionPortrayal2D(Color.yellow)); ((Sugarscape) state).console = console; // reschedule the displayer display.reset();/*from ww w. ja v a 2s . c om*/ // redraw the display display.repaint(); }
From source file:com.google.code.facebook.graph.sna.applet.UnicodeLabelDemo.java
public UnicodeLabelDemo() { // create a simple graph for the demo graph = new DirectedSparseGraph<Integer, Number>(); Integer[] v = createVertices(10); createEdges(v);//w w w . j av a 2s . com vv = new VisualizationViewer<Integer, Number>(new FRLayout<Integer, Number>(graph)); vv.getRenderContext().setVertexLabelTransformer(new UnicodeVertexStringer<Integer>(v)); vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan)); vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan)); VertexIconShapeTransformer<Integer> vertexIconShapeFunction = new VertexIconShapeTransformer<Integer>( new EllipseVertexShapeTransformer<Integer>()); DefaultVertexIconTransformer<Integer> vertexIconFunction = new DefaultVertexIconTransformer<Integer>(); vv.getRenderContext().setVertexShapeTransformer(vertexIconShapeFunction); vv.getRenderContext().setVertexIconTransformer(vertexIconFunction); loadImages(v, vertexIconFunction.getIconMap()); vertexIconShapeFunction.setIconMap(vertexIconFunction.getIconMap()); vv.getRenderContext().setVertexFillPaintTransformer( new PickableVertexPaintTransformer<Integer>(vv.getPickedVertexState(), Color.white, Color.yellow)); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.lightGray)); vv.setBackground(Color.white); // add my listener for ToolTips vv.setVertexToolTipTransformer(new ToStringLabeller<Integer>()); // create a frome to hold the graph final JFrame frame = new JFrame(); Container content = frame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JCheckBox lo = new JCheckBox("Show Labels"); lo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { showLabels = e.getStateChange() == ItemEvent.SELECTED; vv.repaint(); } }); lo.setSelected(true); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); controls.add(lo); controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox()); content.add(controls, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }
From source file:events.MouseEventDemo.java
public MouseEventDemo() { super(new GridLayout(0, 1)); blankArea = new BlankArea(Color.YELLOW); add(blankArea);// w w w.j av a 2s. c om textArea = new JTextArea(); textArea.setEditable(false); JScrollPane scrollPane = new JScrollPane(textArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); scrollPane.setPreferredSize(new Dimension(200, 75)); add(scrollPane); //Register for mouse events on blankArea and the panel. blankArea.addMouseListener(this); addMouseListener(this); setPreferredSize(new Dimension(450, 450)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }