List of usage examples for java.awt Color BLACK
Color BLACK
To view the source code for java.awt Color BLACK.
Click Source Link
From source file:de.jwic.ecolib.controls.chart.ChartControl.java
public void renderImage() throws IOException { // create image to draw into BufferedImage bi = new BufferedImage(width < 10 ? 10 : width, height < 10 ? 10 : height, BufferedImage.TYPE_INT_ARGB); Graphics2D g2d = bi.createGraphics(); if (chart != null) { chart.setBackgroundPaint(Color.WHITE); chart.draw(g2d, new Rectangle2D.Double(0, 0, width < 10 ? 10 : width, height < 10 ? 10 : height)); } else {/* w w w .j a v a2 s . c o m*/ g2d.setColor(Color.BLACK); g2d.drawString("No chart has been assigned.", 1, 20); } // finish drawing g2d.dispose(); // write image data into output stream ByteArrayOutputStream out = getImageOutputStream(); out.reset(); // create a PNG image ImageWriter imageWriter = new PNGImageWriter(null); ImageWriteParam param = imageWriter.getDefaultWriteParam(); imageWriter.setOutput(new MemoryCacheImageOutputStream(out)); imageWriter.write(null, new IIOImage(bi, null, null), param); imageWriter.dispose(); setMimeType(MIME_TYPE_PNG); }
From source file:de.dakror.villagedefense.game.entity.Entity.java
public void drawBump(Graphics2D g, boolean above) { if (bump == null || (!hovered && !clicked)) return;//from ww w . j a v a2 s . co m Color oldColor = g.getColor(); g.setColor(clicked ? Color.black : Color.darkGray); if (above) { g.drawLine((int) x + bump.x, (int) y + bump.y, (int) x + bump.x, (int) y + bump.y + bump.height); // left g.drawLine((int) x + bump.x, (int) y + bump.y + bump.height, (int) x + bump.x + bump.width, (int) y + bump.y + bump.height); // bottom g.drawLine((int) x + bump.x + bump.width, (int) y + bump.y, (int) x + bump.x + bump.width, (int) y + bump.y + bump.height); // right } else { g.drawLine((int) x + bump.x, (int) y + bump.y, (int) x + bump.x + bump.width, (int) y + bump.y); // top } g.setColor(oldColor); }
From source file:com.googlecode.logVisualizer.chart.perDayConsumption.ConsumptionBarChartBuilder.java
private JFreeChart createChart(final ConsumptionDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);//from w w w .ja va 2 s . c om setStackColors(dataset, renderer); renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new ConsumptionLableGenerator()); renderer.setBaseToolTipGenerator(new ConsumptionToolTipGenerator()); categoryAxis.setCategoryMargin(0.07); categoryAxis.setUpperMargin(0.01); categoryAxis.setLowerMargin(0.01); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:ScaleTest_2008.java
/** * Paints the test image that will be downscaled and timed by the various * scaling methods. A different image is rendered into each of the four * quadrants of this image: RGB stripes, a picture, vector art, and * a black and white grid./*from w ww. j av a2s.co m*/ */ private void paintOriginalImage() { Graphics g = originalImage.getGraphics(); // Erase to black g.setColor(Color.BLACK); g.fillRect(0, 0, FULL_SIZE, FULL_SIZE); // RGB quadrant for (int i = 0; i < QUAD_SIZE; i += 3) { int x = i; g.setColor(Color.RED); g.drawLine(x, 0, x, QUAD_SIZE); x++; g.setColor(Color.GREEN); g.drawLine(x, 0, x, QUAD_SIZE); x++; g.setColor(Color.BLUE); g.drawLine(x, 0, x, QUAD_SIZE); } // Picture quadrant try { URL url = getClass().getResource("BBGrayscale.png"); BufferedImage picture = ImageIO.read(url); // Center picture in quadrant area int xDiff = QUAD_SIZE - picture.getWidth(); int yDiff = QUAD_SIZE - picture.getHeight(); g.drawImage(picture, QUAD_SIZE + xDiff / 2, yDiff / 2, null); } catch (Exception e) { System.out.println("Problem reading image file: " + e); } // Vector drawing quadrant g.setColor(Color.WHITE); g.fillRect(0, QUAD_SIZE, QUAD_SIZE, QUAD_SIZE); g.setColor(Color.BLACK); g.drawOval(2, QUAD_SIZE + 2, QUAD_SIZE - 4, QUAD_SIZE - 4); g.drawArc(20, QUAD_SIZE + 20, (QUAD_SIZE - 40), QUAD_SIZE - 40, 190, 160); int eyeSize = 7; int eyePos = 30 - (eyeSize / 2); g.fillOval(eyePos, QUAD_SIZE + eyePos, eyeSize, eyeSize); g.fillOval(QUAD_SIZE - eyePos - eyeSize, QUAD_SIZE + eyePos, eyeSize, eyeSize); // B&W grid g.setColor(Color.WHITE); g.fillRect(QUAD_SIZE + 1, QUAD_SIZE + 1, QUAD_SIZE, QUAD_SIZE); g.setColor(Color.BLACK); for (int i = 0; i < QUAD_SIZE; i += 4) { int pos = QUAD_SIZE + i; g.drawLine(pos, QUAD_SIZE + 1, pos, FULL_SIZE); g.drawLine(QUAD_SIZE + 1, pos, FULL_SIZE, pos); } originalImagePainted = true; }
From source file:org.esa.beam.smos.visat.GridPointBtDataFlagmatrixToolView.java
@Override protected JComponent createGridPointComponent() { dataset = new DefaultXYZDataset(); final NumberAxis xAxis = new NumberAxis("Record #"); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0);//from ww w . jav a 2s.c om xAxis.setUpperMargin(0.0); flagNames = createFlagNames(Dddb.getInstance().getFlagDescriptors(DEFAULT_FLAG_DESCRIPTOR_IDENTIFIER)); final NumberAxis yAxis = createRangeAxis(flagNames); final LookupPaintScale paintScale = new LookupPaintScale(0.0, 4.0, Color.WHITE); paintScale.add(0.0, Color.BLACK); paintScale.add(1.0, Color.RED); paintScale.add(2.0, Color.GREEN); paintScale.add(3.0, Color.BLUE); paintScale.add(4.0, Color.YELLOW); final XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale); renderer.setBaseToolTipGenerator(new FlagToolTipGenerator(flagNames)); plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setForegroundAlpha(0.5f); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage("No data"); chart = new JFreeChart(null, plot); chart.removeLegend(); chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:be.ac.ua.comp.scarletnebula.gui.SSHPanel.java
public SSHPanel(final Server server) { super();/*from w ww .j a v a 2 s.c o m*/ final JCTermSwing term = new JCTermSwing(); term.setCompression(7); term.setAntiAliasing(true); setLayout(new BorderLayout()); addComponentListener(new ComponentListener() { @Override public void componentShown(final ComponentEvent e) { } @Override public void componentResized(final ComponentEvent e) { final Component c = e.getComponent(); int cw = c.getWidth(); int ch = c.getHeight(); final JPanel source = ((JPanel) c); final int cwm = source.getBorder() != null ? source.getBorder().getBorderInsets(c).left + source.getBorder().getBorderInsets(c).right : 0; final int chm = source.getBorder() != null ? source.getBorder().getBorderInsets(c).bottom + source.getBorder().getBorderInsets(c).top : 0; cw -= cwm; ch -= chm; term.setBorder(BorderFactory.createMatteBorder(0, 0, term.getTermHeight() - c.getHeight(), term.getTermWidth() - c.getWidth(), Color.BLACK)); term.setSize(cw, ch); term.setPreferredSize(new Dimension(cw, ch)); // term.setMinimumSize(new Dimension(cw, ch)); term.setMaximumSize(new Dimension(cw, ch)); term.redraw(0, 0, term.getTermWidth(), term.getTermHeight()); } @Override public void componentMoved(final ComponentEvent e) { // TODO // Auto-generated // method // stub } @Override public void componentHidden(final ComponentEvent e) { // TODO // Auto-generated // method // stub } }); add(term, BorderLayout.CENTER); setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20), BorderFactory.createBevelBorder(BevelBorder.LOWERED))); final Thread connectionThread = new Thread() { @Override public void run() { Connection connection = null; try { final SSHCommandConnection commandConnection = (SSHCommandConnection) server .newCommandConnection(new NotPromptingJschUserInfo()); connection = commandConnection.getJSchTerminalConnection(); term.requestFocusInWindow(); term.start(connection); } catch (final Exception e) { for (final ExceptionListener listener : exceptionListeners) { listener.exceptionThrown(e); } log.warn("Exception thrown by SSHPanel", e); } finally { } } }; connectionThread.start(); }
From source file:EditorPaneExample9.java
public EditorPaneExample9() { super("JEditorPane Example 9"); 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;// w w w.j a v a 2s.c o 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.gridy = 3; panel.add(new JLabel(LOAD_TIME), c); c.gridy = 4; c.gridwidth = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; onlineLoad = new JCheckBox("Online Load"); panel.add(onlineLoad, c); onlineLoad.setSelected(true); onlineLoad.setForeground(typeLabel.getForeground()); c.gridx = 1; c.gridy = 0; c.anchor = GridBagConstraints.EAST; 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); timeLabel = new JLabel(""); c.gridy = 3; panel.add(timeLabel, 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); timeLabel.setText(""); timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height); startTime = System.currentTimeMillis(); // Choose the loading method if (onlineLoad.isSelected()) { // Usual load via setPage pane.setPage(url); loadedType.setText(pane.getContentType()); } else { pane.setContentType("text/html"); loadedType.setText(pane.getContentType()); if (loader == null) { loader = new HTMLDocumentLoader(); } HTMLDocument doc = loader.loadDocument(new URL(url)); loadComplete(); pane.setDocument(doc); displayLoadTime(); } } 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")) { loadComplete(); displayLoadTime(); } } }); }
From source file:org.jfree.graphics2d.demo.CanvasBarChartDemo1.java
/** * Creates a sample chart./*from www . j a v a 2 s. com*/ * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", // chart title "Type", // domain axis label "Value", // range axis label dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setDrawBarOutline(false); renderer.setErrorIndicatorPaint(Color.black); renderer.setIncludeBaseInRange(false); plot.setRenderer(renderer); // ensure the current theme is applied to the renderer just added ChartUtilities.applyCurrentTheme(chart); renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultItemLabelPaint(Color.yellow); renderer.setDefaultPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); return chart; }
From source file:com.googlecode.logVisualizer.chart.HorizontalStackedBarChartBuilder.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.HORIZONTAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);//w w w. j av a 2s .c o m renderer.setDrawBarOutline(false); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); categoryAxis.setCategoryMargin(0.02); categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:ws.moor.bt.grapher.ChartBuilder.java
public JFreeChart getChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries, showLegend && (timeSeries.getSeriesCount() > 1), false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot();/*w w w . j av a2 s . c o m*/ plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getRenderer().setSeriesPaint(0, Color.black); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesPaint(1, Color.black); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesPaint(2, Color.black); plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f)); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }