List of usage examples for java.awt Color LIGHT_GRAY
Color LIGHT_GRAY
To view the source code for java.awt Color LIGHT_GRAY.
Click Source Link
From source file:cgpanalyser.gui.MainWindow.java
private void checkBoxGreyUnusedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkBoxGreyUnusedActionPerformed if (checkBoxGreyUnused.isSelected()) dVars.setUsedColorMain(Color.LIGHT_GRAY); else//from w ww.j av a2s .co m dVars.setUsedColorMain(null); repaint(); }
From source file:net.sf.fspdfs.chartthemes.spring.AegeanChartTheme.java
/** * *///ww w . j a v a 2s.c o m protected JFreeChart createMeterChart() throws JRException { // Start by creating the plot that will hold the meter MeterPlot chartPlot = new MeterPlot((ValueDataset) getDataset()); JRMeterPlot jrPlot = (JRMeterPlot) getPlot(); // Set the shape MeterShapeEnum shape = jrPlot.getShapeValue() == null ? MeterShapeEnum.DIAL : jrPlot.getShapeValue(); switch (shape) { case CHORD: chartPlot.setDialShape(DialShape.CHORD); break; case PIE: chartPlot.setDialShape(DialShape.PIE); break; case CIRCLE: chartPlot.setDialShape(DialShape.CIRCLE); break; case DIAL: default: return createDialChart(); } chartPlot.setDialOutlinePaint(Color.BLACK); int meterAngle = jrPlot.getMeterAngleInteger() == null ? 180 : jrPlot.getMeterAngleInteger().intValue(); // Set the size of the meter chartPlot.setMeterAngle(meterAngle); // Set the spacing between ticks. I hate the name "tickSize" since to me it // implies I am changing the size of the tick, not the spacing between them. double tickInterval = jrPlot.getTickIntervalDouble() == null ? 10.0 : jrPlot.getTickIntervalDouble().doubleValue(); chartPlot.setTickSize(tickInterval); JRFont tickLabelFont = jrPlot.getTickLabelFont(); Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE); Font themeTickLabelFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT), tickLabelFont, defaultBaseFontSize); chartPlot.setTickLabelFont(themeTickLabelFont); Color tickColor = jrPlot.getTickColor() == null ? Color.BLACK : jrPlot.getTickColor(); chartPlot.setTickPaint(tickColor); int dialUnitScale = 1; Range range = convertRange(jrPlot.getDataRange()); if (range != null) { // Set the meter's range chartPlot.setRange(range); double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound())); dialUnitScale = ChartThemesUtilities.getScale(bound); if ((range.getLowerBound() == (int) range.getLowerBound() && range.getUpperBound() == (int) range.getUpperBound() && tickInterval == (int) tickInterval) || dialUnitScale > 1) { chartPlot.setTickLabelFormat(new DecimalFormat("#,##0")); } else if (dialUnitScale == 1) { chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.0")); } else if (dialUnitScale <= 0) { chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.00")); } } chartPlot.setTickLabelsVisible(true); // Set all the colors we support Paint backgroundPaint = jrPlot.getOwnBackcolor() == null ? ChartThemesConstants.TRANSPARENT_PAINT : jrPlot.getOwnBackcolor(); chartPlot.setBackgroundPaint(backgroundPaint); GradientPaint gp = new GradientPaint(new Point(), Color.LIGHT_GRAY, new Point(), Color.BLACK, false); if (jrPlot.getMeterBackgroundColor() != null) { chartPlot.setDialBackgroundPaint(jrPlot.getMeterBackgroundColor()); } else { chartPlot.setDialBackgroundPaint(gp); } //chartPlot.setForegroundAlpha(1f); Paint needlePaint = jrPlot.getNeedleColor() == null ? new Color(191, 48, 0) : jrPlot.getNeedleColor(); chartPlot.setNeedlePaint(needlePaint); JRValueDisplay display = jrPlot.getValueDisplay(); if (display != null) { Color valueColor = display.getColor() == null ? Color.BLACK : display.getColor(); chartPlot.setValuePaint(valueColor); String pattern = display.getMask() != null ? display.getMask() : "#,##0.####"; if (pattern != null) chartPlot.setTickLabelFormat(new DecimalFormat(pattern)); JRFont displayFont = display.getFont(); Font themeDisplayFont = getFont( (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT), displayFont, defaultBaseFontSize); if (themeDisplayFont != null) { chartPlot.setValueFont(themeDisplayFont); } } String label = getChart().hasProperties() ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL) : null; if (label != null) { if (dialUnitScale < 0) label = new MessageFormat(label) .format(new Object[] { String.valueOf(Math.pow(10, dialUnitScale)) }); else if (dialUnitScale < 3) label = new MessageFormat(label).format(new Object[] { "1" }); else label = new MessageFormat(label) .format(new Object[] { String.valueOf((int) Math.pow(10, dialUnitScale - 2)) }); } // Set the units - this is just a string that will be shown next to the // value String units = jrPlot.getUnits() == null ? label : jrPlot.getUnits(); if (units != null && units.length() > 0) chartPlot.setUnits(units); chartPlot.setTickPaint(Color.BLACK); // Now define all of the intervals, setting their range and color List intervals = jrPlot.getIntervals(); if (intervals != null && intervals.size() > 0) { int size = Math.min(3, intervals.size()); int colorStep = 0; if (size > 3) colorStep = 255 / (size - 3); for (int i = 0; i < size; i++) { JRMeterInterval interval = (JRMeterInterval) intervals.get(i); Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i) : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0); interval.setBackgroundColor(color); interval.setAlpha(new Double(1.0)); chartPlot.addInterval(convertInterval(interval)); } } // Actually create the chart around the plot JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null, chartPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend().booleanValue()); // Set all the generic options configureChart(jfreeChart, getPlot()); return jfreeChart; }
From source file:edu.harvard.i2b2.patientMapping.ui.PatientMappingJPanel.java
private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jLabel1 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jSaveButton = new javax.swing.JButton(); jImportButton = new javax.swing.JButton(); jConvertButton = new javax.swing.JButton(); jAutoSaveCheckBox = new javax.swing.JCheckBox(); jPanel2 = new javax.swing.JPanel(); jRightButton = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); jLeftButton = new javax.swing.JButton(); jStartTextField = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jIncrementTextField = new javax.swing.JTextField(); setLayout(new java.awt.GridBagLayout()); setMinimumSize(new java.awt.Dimension(0, 0)); jLabel1.setText(" Patient Mapping Table:"); jLabel1.setAlignmentX(0.5F);//from w w w . j av a2s . co m jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jLabel1.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jLabel1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { jNameLabelMouseMoved(evt); } }); jLabel1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jNameLabelMouseExited(evt); } }); jLabel1.addMouseListener(new DragMouseAdapter()); jLabel1.setTransferHandler(new NameLabelTextHandler()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 390; gridBagConstraints.ipady = 4; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(3, 2, 0, 3); add(jLabel1, gridBagConstraints); jTable1.setModel( new javax.swing.table.DefaultTableModel( new Object[][] { { null, null, null, null }, { null, null, null, null }, { null, null, null, null }, { null, null, null, null } }, new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); jScrollPane1.setViewportView(jTable1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.ipadx = 486; gridBagConstraints.ipady = 160; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0); add(jScrollPane1, gridBagConstraints); jPanel1.setLayout(new java.awt.GridBagLayout()); jSaveButton.setText("Save Patient Set"); jSaveButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jSaveButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.ipady = -3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 40, 1, 0); jPanel1.add(jSaveButton, gridBagConstraints); jImportButton.setText("Open Patient Set"); jImportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jImportButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.ipadx = 3; gridBagConstraints.ipady = -3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 21, 1, 0); jPanel1.add(jImportButton, gridBagConstraints); jConvertButton.setText("Convert Between Patient Sets"); jConvertButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jConvertButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.ipady = -3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 10, 1, 1); jPanel1.add(jConvertButton, gridBagConstraints); jAutoSaveCheckBox.setText("save patients to a file automatically"); jAutoSaveCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); jAutoSaveCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.ipadx = 33; gridBagConstraints.ipady = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 10, 1, 0); jPanel1.add(jAutoSaveCheckBox, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 509; gridBagConstraints.ipady = 1; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(1, 11, 5, 0); add(jPanel1, gridBagConstraints); jPanel2.setLayout(new java.awt.GridBagLayout()); jRightButton.setText(">"); jRightButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRightButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 6; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 10, 8, 5); //jPanel2.add(jRightButton, gridBagConstraints); jLabel2.setText("Patient Set Size: --- "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.ipady = 6; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 17, 0, 0); jPanel2.add(jLabel2, gridBagConstraints); jLeftButton.setText("Cancel"); jLeftButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jLeftButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 24, 8, 0); jPanel2.add(jLeftButton, gridBagConstraints); //jLeftButton.setBackground(Color.LIGHT_GRAY); jPanel2.setBackground(Color.LIGHT_GRAY); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 44; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 3, 0, 0); //jPanel2.add(jStartTextField, gridBagConstraints); jLabel3.setText("start:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 17, 0, 0); //jPanel2.add(jLabel3, gridBagConstraints); jLabel4.setText("increment:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 4; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0); //jPanel2.add(jLabel4, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 44; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(10, 9, 0, 0); //jPanel2.add(jIncrementTextField, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 33; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; add(jPanel2, gridBagConstraints); }
From source file:com.rapidminer.gui.plotter.charts.MultipleScatterPlotter.java
@Override public void updatePlotter() { prepareData();//from w ww . jav a 2 s . co m JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // URLs ); if (xAxis >= 0) { int size = dataSet.getSeriesCount(); chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // URLs ); // renderer settings XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setBaseOutlinePaint(Color.BLACK); renderer.setUseOutlinePaint(true); renderer.setDrawOutlines(true); for (int i = 0; i < size; i++) { renderer.setSeriesShapesVisible(i, this.showPoints[plotIndexToColumnIndexMap.get(i)]); renderer.setSeriesLinesVisible(i, this.showLines[plotIndexToColumnIndexMap.get(i)]); } renderer.setSeriesShape(0, new Ellipse2D.Double(-3, -3, 7, 7)); // legend settings LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setPosition(RectangleEdge.TOP); legend.setFrame(BlockBorder.NONE); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); legend.setItemFont(LABEL_FONT); } } // GENERAL CHART SETTINGS int size = dataSet.getSeriesCount(); if (size <= 1) { chart.getXYPlot().getRenderer().setSeriesPaint(0, getColorProvider().getPointColor(1.0d)); } else { for (int i = 0; i < dataSet.getSeriesCount(); i++) { chart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); chart.getXYPlot().getRenderer().setSeriesPaint(i, getColorProvider().getPointColor(i / (double) (dataSet.getSeriesCount() - 1))); } } // set the background colors for the chart... chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); chart.setAntiAlias(false); // general plot settings XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); // domain axis if (xAxis >= 0) { if (dataTable.isNominal(xAxis)) { String[] values = new String[dataTable.getNumberOfValues(xAxis)]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(xAxis, i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(xAxis), values)); } else if ((dataTable.isDate(xAxis)) || (dataTable.isDateTime(xAxis))) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(xAxis)); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (xLogScale) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(xAxis)); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(xAxis)); domainAxis.setAutoRangeStickyZero(false); domainAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(domainAxis); } } } plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD); plot.getDomainAxis().setTickLabelFont(LABEL_FONT); // rotate labels if (isLabelRotating()) { plot.getDomainAxis().setTickLabelsVisible(true); plot.getDomainAxis().setVerticalTickLabels(true); } // range axis plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); // Chart Panel Settings if (panel instanceof AbstractChartPanel) { panel.setChart(chart); } else { panel = new AbstractChartPanel(chart, getWidth(), getHeight() - MARGIN); final ChartPanelShiftController controller = new ChartPanelShiftController(panel); panel.addMouseListener(controller); panel.addMouseMotionListener(controller); // react to mouse clicks // ATTENTION: ACTIVATING THIS WILL LEAD TO SEVERE MEMORY LEAKS!!! (see below) panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (e.getTrigger().getClickCount() > 1) { XYItemEntity entity = (XYItemEntity) e.getEntity(); if (entity != null) { String id = idMap.get(new SeriesAndItem(entity.getSeriesIndex(), entity.getItem())); if (id != null) { ObjectVisualizer visualizer = ObjectVisualizerService .getVisualizerForObject(dataTable); visualizer.startVisualization(id); } } } } @Override public void chartMouseMoved(ChartMouseEvent e) { } }); } // tooltips class CustomXYToolTipGenerator implements XYToolTipGenerator { public CustomXYToolTipGenerator() { } @Override public String generateToolTip(XYDataset dataset, int row, int column) { String id = idMap.get(new SeriesAndItem(row, column)); if (id != null) { return "<html><b>Id: " + id + "</b> (" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } else { return "<html>(" + dataset.getSeriesKey(row) + ", " + Tools.formatIntegerIfPossible(dataset.getXValue(row, column)) + ", " + Tools.formatIntegerIfPossible(dataset.getYValue(row, column)) + ")</html>"; } } } for (int i = 0; i < dataSet.getSeriesCount(); i++) { plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator()); } }
From source file:com.ctsim.dmi.MainFrame.java
private void drawTime() { now = Calendar.getInstance(); g2.setColor(Color.LIGHT_GRAY); g2.setFont(new Font("Loma", Font.BOLD, 20)); g2.drawString(sdf.format(now.getTime()), 800, 720); }
From source file:org.openmicroscopy.shoola.agents.util.SelectionWizardUI.java
/** * Sets the default text for the specified field. * * @param text The text to display//from ww w. j a va 2 s. c o m */ private void setTextFieldDefault(String text) { filterArea.getDocument().removeDocumentListener(this); if (text == null) { filterArea.setText(""); filterArea.setForeground(originalColor); } else { filterArea.setText(text); filterArea.setForeground(Color.LIGHT_GRAY); } filterArea.getDocument().addDocumentListener(this); }
From source file:org.apache.fop.render.pcl.PCLPainter.java
private void drawTextAsBitmap(final int x, final int y, final int letterSpacing, final int wordSpacing, final int[] dx, final String text, FontTriplet triplet) throws IFException { //Use Java2D to paint different fonts via bitmap final Font font = parent.getFontInfo().getFontInstance(triplet, state.getFontSize()); //for cursive fonts, so the text isn't clipped final FontMetricsMapper mapper = (FontMetricsMapper) parent.getFontInfo().getMetricsFor(font.getFontName()); final int maxAscent = mapper.getMaxAscent(font.getFontSize()) / 1000; final int ascent = mapper.getAscender(font.getFontSize()) / 1000; final int descent = mapper.getDescender(font.getFontSize()) / 1000; int safetyMargin = (int) (SAFETY_MARGIN_FACTOR * font.getFontSize()); final int baselineOffset = maxAscent + safetyMargin; final Rectangle boundingBox = getTextBoundingBox(x, y, letterSpacing, wordSpacing, dx, text, font, mapper); final Dimension dim = boundingBox.getSize(); Graphics2DImagePainter painter = new Graphics2DImagePainter() { public void paint(Graphics2D g2d, Rectangle2D area) { if (DEBUG) { g2d.setBackground(Color.LIGHT_GRAY); g2d.clearRect(0, 0, (int) area.getWidth(), (int) area.getHeight()); }//w w w .j av a 2 s. c o m g2d.translate(-x, -y + baselineOffset); if (DEBUG) { Rectangle rect = new Rectangle(x, y - maxAscent, 3000, maxAscent); g2d.draw(rect); rect = new Rectangle(x, y - ascent, 2000, ascent); g2d.draw(rect); rect = new Rectangle(x, y, 1000, -descent); g2d.draw(rect); } Java2DPainter painter = new Java2DPainter(g2d, getContext(), parent.getFontInfo(), state); try { painter.drawText(x, y, letterSpacing, wordSpacing, dx, text); } catch (IFException e) { //This should never happen with the Java2DPainter throw new RuntimeException("Unexpected error while painting text", e); } } public Dimension getImageSize() { return dim.getSize(); } }; paintMarksAsBitmap(painter, boundingBox); }
From source file:edu.unibonn.kmeans.mapreduce.plotting.TimeSeriesPlotter_KMeans.java
private Paint getColor(int color_number) { Color curr_color = null;/*www. j a va 2 s . c o m*/ switch (color_number) { case 0: curr_color = Color.BLUE; break; case 1: curr_color = Color.GREEN; break; case 2: curr_color = Color.RED; break; case 3: curr_color = Color.PINK; break; case 4: curr_color = Color.MAGENTA; break; case 5: curr_color = Color.CYAN; break; case 6: curr_color = Color.DARK_GRAY; break; case 7: curr_color = Color.LIGHT_GRAY; break; case 8: curr_color = Color.YELLOW; break; case 9: curr_color = Color.ORANGE; break; case 10: curr_color = Color.BLACK; break; // case 11: curr_color = Color.YELLOW; // break; // case 12: curr_color = Color.BLACK; // break; // case 13: curr_color = Color.BLACK; // break; // case 14: curr_color = Color.BLACK; // break; // case 15: curr_color = Color.BLACK; // break; // case 16: curr_color = Color.BLACK; // break; // case 17: curr_color = Color.BLACK; // break; // case 18: curr_color = Color.BLACK; // break; // case 20: curr_color = Color.BLACK; // break; // case 21: curr_color = Color.BLACK; // break; // case 22: curr_color = Color.BLACK; // break; // case 23: curr_color = Color.BLACK; // break; default: curr_color = Color.WHITE; break; } return curr_color; }
From source file:com.rapidminer.gui.viewer.metadata.AttributeStatisticsPanel.java
/** * Initializes the GUI.//w w w. j a v a 2 s . c o m * */ @SuppressWarnings({ "unchecked", "rawtypes" }) private void initGUI() { setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); // add attribute name panelAttName = new JPanel(); panelAttName.setLayout(new BoxLayout(panelAttName, BoxLayout.PAGE_AXIS)); panelAttName.setOpaque(false); // this border is to visualize that the name column can be enlarged/shrinked panelAttName.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.LIGHT_GRAY)); labelAttHeader = new JLabel(LABEL_DOTS); labelAttHeader.setFont(labelAttHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAttHeader.setForeground(Color.GRAY); panelAttName.add(labelAttHeader); labelAttName = new JLabel(LABEL_DOTS); labelAttName.setFont(labelAttName.getFont().deriveFont(Font.BOLD, FONT_SIZE_LABEL_VALUE)); labelAttName.setMinimumSize(DIMENSION_LABEL_ATTRIBUTE); labelAttName.setPreferredSize(DIMENSION_LABEL_ATTRIBUTE); panelAttName.add(labelAttName); gbc.gridx = 0; gbc.gridy = 0; gbc.insets = new Insets(3, 20, 3, 10); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0.0; gbc.weighty = 1.0; gbc.gridheight = 2; add(panelAttName, gbc); // create value type name and bring it to a nice to read format (aka uppercase first letter // and replace '_' with ' ' gbc.gridx += 1; gbc.insets = new Insets(5, 15, 5, 10); labelAttType = new JLabel(LABEL_DOTS); labelAttType.setMinimumSize(DIMENSION_LABEL_TYPE); labelAttType.setPreferredSize(DIMENSION_LABEL_TYPE); add(labelAttType, gbc); // missings panel JPanel panelStatsMissing = new JPanel(); panelStatsMissing.setLayout(new BoxLayout(panelStatsMissing, BoxLayout.PAGE_AXIS)); panelStatsMissing.setOpaque(false); labelStatsMissing = new JLabel(LABEL_DOTS); labelStatsMissing.setMinimumSize(DIMENSION_LABEL_MISSINGS); labelStatsMissing.setPreferredSize(DIMENSION_LABEL_MISSINGS); panelStatsMissing.add(labelStatsMissing); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsMissing, gbc); // chart panel(s) (only visible when enlarged) JPanel chartPanel = new JPanel(new BorderLayout()); chartPanel.setBackground(COLOR_TRANSPARENT); chartPanel.setOpaque(false); listOfChartPanels.add(chartPanel); updateVisibilityOfChartPanels(); gbc.fill = GridBagConstraints.NONE; gbc.weighty = 0.0; gbc.insets = new Insets(0, 10, 0, 10); for (JPanel panel : listOfChartPanels) { gbc.gridx += 1; add(panel, gbc); } // (hidden) construction panel String constructionLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.construction.label"); panelStatsConstruction = new JPanel(); panelStatsConstruction.setLayout(new BoxLayout(panelStatsConstruction, BoxLayout.PAGE_AXIS)); panelStatsConstruction.setOpaque(false); panelStatsConstruction.setVisible(false); JLabel labelConstructionHeader = new JLabel(constructionLabel); labelConstructionHeader.setFont(labelConstructionHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelConstructionHeader.setForeground(Color.GRAY); panelStatsConstruction.add(labelConstructionHeader); labelStatsConstruction = new JLabel(LABEL_DOTS); labelStatsConstruction.setFont(labelStatsConstruction.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); labelStatsConstruction.setMinimumSize(DIMENSION_LABEL_CONSTRUCTION); labelStatsConstruction.setPreferredSize(DIMENSION_LABEL_CONSTRUCTION); panelStatsConstruction.add(labelStatsConstruction); gbc.gridx += 1; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; add(panelStatsConstruction, gbc); // statistics panel, contains different statistics panels for numerical/nominal/date_time on // a card layout // needed to switch between for model swapping cardStatsPanel = new JPanel(); cardStatsPanel.setOpaque(false); cardLayout = new CardLayout(); cardStatsPanel.setLayout(cardLayout); // numerical version JPanel statsNumPanel = new JPanel(); GridBagLayout layout = new GridBagLayout(); GridBagConstraints gbcStatPanel = new GridBagConstraints(); statsNumPanel.setLayout(layout); statsNumPanel.setOpaque(false); String avgLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.avg.label"); String devianceLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.variance.label"); String minLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.min.label"); String maxLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.max.label"); // min value panel JPanel panelStatsMin = new JPanel(); panelStatsMin.setLayout(new BoxLayout(panelStatsMin, BoxLayout.PAGE_AXIS)); panelStatsMin.setOpaque(false); JLabel labelMinHeader = new JLabel(minLabel); labelMinHeader.setFont(labelMinHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMinHeader.setForeground(Color.GRAY); panelStatsMin.add(labelMinHeader); labelStatsMin = new JLabel(LABEL_DOTS); labelStatsMin.setFont(labelStatsMin.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMin.add(labelStatsMin); // max value panel JPanel panelStatsMax = new JPanel(); panelStatsMax.setLayout(new BoxLayout(panelStatsMax, BoxLayout.PAGE_AXIS)); panelStatsMax.setOpaque(false); JLabel labelMaxHeader = new JLabel(maxLabel); labelMaxHeader.setFont(labelMaxHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMaxHeader.setForeground(Color.GRAY); panelStatsMax.add(labelMaxHeader); labelStatsMax = new JLabel(LABEL_DOTS); labelStatsMax.setFont(labelStatsMax.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMax.add(labelStatsMax); // average value panel JPanel panelStatsAvg = new JPanel(); panelStatsAvg.setLayout(new BoxLayout(panelStatsAvg, BoxLayout.PAGE_AXIS)); panelStatsAvg.setOpaque(false); JLabel labelAvgHeader = new JLabel(avgLabel); labelAvgHeader.setFont(labelAvgHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelAvgHeader.setForeground(Color.GRAY); panelStatsAvg.add(labelAvgHeader); labelStatsAvg = new JLabel(LABEL_DOTS); labelStatsAvg.setFont(labelStatsAvg.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsAvg.add(labelStatsAvg); // deviance value panel JPanel panelStatsDeviance = new JPanel(); panelStatsDeviance.setLayout(new BoxLayout(panelStatsDeviance, BoxLayout.PAGE_AXIS)); panelStatsDeviance.setOpaque(false); JLabel labelDevianceHeader = new JLabel(devianceLabel); labelDevianceHeader.setFont(labelDevianceHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDevianceHeader.setForeground(Color.GRAY); panelStatsDeviance.add(labelDevianceHeader); labelStatsDeviation = new JLabel(LABEL_DOTS); labelStatsDeviation.setFont(labelStatsDeviation.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDeviance.add(labelStatsDeviation); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 4); panelStatsMin.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMin, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMax.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsMax, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsAvg.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsAvg, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDeviance.setPreferredSize(DIMENSION_PANEL_NUMERIC_PREF_SIZE); statsNumPanel.add(panelStatsDeviance, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNumPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNumPanel, CARD_NUMERICAL); // nominal version JPanel statsNomPanel = new JPanel(); statsNomPanel.setLayout(layout); statsNomPanel.setOpaque(false); String leastLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.least.label"); String mostLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.most.label"); String valuesLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.values.label"); // least panel JPanel panelStatsLeast = new JPanel(); panelStatsLeast.setLayout(new BoxLayout(panelStatsLeast, BoxLayout.PAGE_AXIS)); panelStatsLeast.setOpaque(false); JLabel labelLeastHeader = new JLabel(leastLabel); labelLeastHeader.setFont(labelLeastHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelLeastHeader.setForeground(Color.GRAY); labelLeastHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsLeast.add(labelLeastHeader); labelStatsLeast = new JLabel(LABEL_DOTS); labelStatsLeast.setFont(labelStatsLeast.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsLeast.add(labelStatsLeast); // most panel JPanel panelStatsMost = new JPanel(); panelStatsMost.setLayout(new BoxLayout(panelStatsMost, BoxLayout.PAGE_AXIS)); panelStatsMost.setOpaque(false); JLabel labelMostHeader = new JLabel(mostLabel); labelMostHeader.setFont(labelMostHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelMostHeader.setForeground(Color.GRAY); labelMostHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsMost.add(labelMostHeader); labelStatsMost = new JLabel(LABEL_DOTS); labelStatsMost.setFont(labelStatsMost.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsMost.add(labelStatsMost); // values panel JPanel panelStatsValues = new JPanel(); panelStatsValues.setLayout(new BoxLayout(panelStatsValues, BoxLayout.PAGE_AXIS)); panelStatsValues.setOpaque(false); JLabel labelValuesHeader = new JLabel(valuesLabel); labelValuesHeader.setFont(labelValuesHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelValuesHeader.setForeground(Color.GRAY); labelValuesHeader.setAlignmentX(Component.LEFT_ALIGNMENT); panelStatsValues.add(labelValuesHeader); labelStatsValues = new JLabel(LABEL_DOTS); labelStatsValues.setFont(labelStatsValues.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsValues.add(labelStatsValues); detailsButton = new JButton(new ShowNomValueAction(this)); detailsButton.setVisible(false); detailsButton.setOpaque(false); detailsButton.setContentAreaFilled(false); detailsButton.setBorderPainted(false); detailsButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter); detailsButton.setHorizontalAlignment(SwingConstants.LEFT); detailsButton.setHorizontalTextPosition(SwingConstants.LEFT); detailsButton.setIcon(null); Font font = detailsButton.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); detailsButton.setFont(font.deriveFont(attributes)); panelStatsValues.add(detailsButton); // add sub panel to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsLeast.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsLeast, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsMost.setPreferredSize(DIMENSION_PANEL_NOMINAL_PREF_SIZE); statsNomPanel.add(panelStatsMost, gbcStatPanel); gbcStatPanel.gridx += 1; statsNomPanel.add(panelStatsValues, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsNomPanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsNomPanel, CARD_NOMINAL); // date_time version JPanel statsDateTimePanel = new JPanel(); statsDateTimePanel.setLayout(layout); statsDateTimePanel.setOpaque(false); String durationLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.duration.label"); String fromLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.from.label"); String untilLabel = I18N.getMessage(I18N.getGUIBundle(), "gui.label.attribute_statistics.statistics.until.label"); // min value panel JPanel panelStatsFrom = new JPanel(); panelStatsFrom.setLayout(new BoxLayout(panelStatsFrom, BoxLayout.PAGE_AXIS)); panelStatsFrom.setOpaque(false); JLabel labelFromHeader = new JLabel(fromLabel); labelFromHeader.setFont(labelFromHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelFromHeader.setForeground(Color.GRAY); panelStatsFrom.add(labelFromHeader); labelStatsFrom = new JLabel(LABEL_DOTS); labelStatsFrom.setFont(labelStatsFrom.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsFrom.add(labelStatsFrom); // until value panel JPanel panelStatsUntil = new JPanel(); panelStatsUntil.setLayout(new BoxLayout(panelStatsUntil, BoxLayout.PAGE_AXIS)); panelStatsUntil.setOpaque(false); JLabel labelUntilHeader = new JLabel(untilLabel); labelUntilHeader.setFont(labelUntilHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelUntilHeader.setForeground(Color.GRAY); panelStatsUntil.add(labelUntilHeader); labelStatsUntil = new JLabel(LABEL_DOTS); labelStatsUntil.setFont(labelStatsUntil.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsUntil.add(labelStatsUntil); // duration value panel JPanel panelStatsDuration = new JPanel(); panelStatsDuration.setLayout(new BoxLayout(panelStatsDuration, BoxLayout.PAGE_AXIS)); panelStatsDuration.setOpaque(false); JLabel labelDurationHeader = new JLabel(durationLabel); labelDurationHeader.setFont(labelDurationHeader.getFont().deriveFont(FONT_SIZE_LABEL_HEADER)); labelDurationHeader.setForeground(Color.GRAY); panelStatsDuration.add(labelDurationHeader); labelStatsDuration = new JLabel(LABEL_DOTS); labelStatsDuration.setFont(labelStatsDuration.getFont().deriveFont(FONT_SIZE_LABEL_VALUE)); panelStatsDuration.add(labelStatsDuration); // add sub panels to stats panel gbcStatPanel.gridx = 0; gbcStatPanel.weightx = 0.0; gbcStatPanel.fill = GridBagConstraints.NONE; gbcStatPanel.insets = new Insets(0, 0, 0, 6); panelStatsFrom.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsFrom, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsUntil.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsUntil, gbcStatPanel); gbcStatPanel.gridx += 1; panelStatsDuration.setPreferredSize(DIMENSION_PANEL_DATE_PREF_SIZE); statsDateTimePanel.add(panelStatsDuration, gbcStatPanel); gbcStatPanel.gridx += 1; gbcStatPanel.weightx = 1.0; gbcStatPanel.fill = GridBagConstraints.HORIZONTAL; statsDateTimePanel.add(new JLabel(), gbcStatPanel); cardStatsPanel.add(statsDateTimePanel, CARD_DATE_TIME); // add stats panel to main gui gbc.gridx += 1; gbc.insets = new Insets(5, 10, 5, 10); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1.0; gbc.weighty = 0.0; gbc.anchor = GridBagConstraints.WEST; add(cardStatsPanel, gbc); // needed so we can draw our own background setOpaque(false); // handle mouse events for hover effect and enlarging/shrinking addMouseListener(enlargeAndHoverAndPopupMouseAdapter); // change cursor to indicate this component can be clicked setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); }
From source file:tools.descartes.bungee.chart.ChartGenerator.java
private static void customizePlot(final XYPlot plot) { plot.setOutlinePaint(null);/* ww w. j ava2 s. co m*/ plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); //plot.setShadowGenerator(new DefaultShadowGenerator()); Font font = new Font("Dialog", Font.PLAIN, 20); Font labelFont = new Font("Dialog", Font.PLAIN, 16); plot.getDomainAxis().setLabelFont(labelFont); plot.getRangeAxis().setLabelFont(labelFont); plot.getDomainAxis().setTickLabelFont(font); plot.getRangeAxis().setTickLabelFont(font); }