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:dbseer.gui.user.DBSeerDataSet.java
protected Object readResolve() { useDefaultIfNull();//from w w w . j av a 2s. c o m Boolean[] trueFalse = { Boolean.TRUE, Boolean.FALSE }; JComboBox trueFalseBox = new JComboBox(trueFalse); final DefaultCellEditor dce = new DefaultCellEditor(trueFalseBox); uniqueVariableName = "dataset_" + UUID.randomUUID().toString().replace('-', '_'); tableModel = new DBSeerDataSetTableModel(null, new String[] { "Name", "Value" }, true); tableModel.addTableModelListener(this); table = new JTable(tableModel) { @Override public TableCellEditor getCellEditor(int row, int col) { if ((row == DBSeerDataSet.TYPE_USE_ENTIRE_DATASET || row > TYPE_NUM_TRANSACTION_TYPE + numTransactionTypes) && col == 1) return dce; return super.getCellEditor(row, col); } }; DefaultTableCellRenderer customRenderer = new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(JTable jTable, Object o, boolean b, boolean b2, int row, int col) { Component cell = super.getTableCellRendererComponent(jTable, o, b, b2, row, col); if (row == DBSeerDataSet.TYPE_START_INDEX || row == DBSeerDataSet.TYPE_END_INDEX) { if (((Boolean) table.getValueAt(DBSeerDataSet.TYPE_USE_ENTIRE_DATASET, 1)) .booleanValue() == true) { cell.setForeground(Color.LIGHT_GRAY); } else { cell.setForeground(Color.BLACK); } } else if (row == DBSeerDataSet.TYPE_NUM_TRANSACTION_TYPE) { cell.setForeground(Color.LIGHT_GRAY); } else { cell.setForeground(Color.BLACK); } return cell; } }; table.getColumnModel().getColumn(0).setCellRenderer(customRenderer); table.getColumnModel().getColumn(1).setCellRenderer(customRenderer); table.setFillsViewportHeight(true); table.getColumnModel().getColumn(0).setMaxWidth(400); table.getColumnModel().getColumn(0).setPreferredWidth(300); table.getColumnModel().getColumn(1).setPreferredWidth(600); table.setRowHeight(20); for (String header : tableHeaders) { if (header.equalsIgnoreCase("Use Entire DataSet")) tableModel.addRow(new Object[] { header, Boolean.TRUE }); else tableModel.addRow(new Object[] { header, "" }); } for (int i = 0; i < transactionTypes.size(); ++i) { DBSeerTransactionType txType = transactionTypes.get(i); tableModel.addRow(new Object[] { "Name of Transaction Type " + (i + 1), txType.getName() }); } if (live) { updateLiveDataSet(); } for (int i = 0; i < transactionTypes.size(); ++i) { DBSeerTransactionType txType = transactionTypes.get(i); if (txType.isEnabled()) { tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.TRUE }); } else { tableModel.addRow(new Object[] { "Use Transaction Type " + (i + 1), Boolean.FALSE }); } } this.updateTable(); dataSetLoaded = false; tableModel.setUseEntireDataSet(this.useEntireDataSet.booleanValue()); return this; }
From source file:it.unifi.rcl.chess.traceanalysis.gui.TracePanel.java
private void plotCompare() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries xyBoundsPositive = null;//from w w w . ja va2 s. c o m XYSeries xyBoundsNegative = null; Trace[] posNeg = null; Component[] siblings = this.getParent().getComponents(); Trace[] allTraces = new Trace[siblings.length]; int rows = tableWindowSize.getRowCount(); double coverage = 0.99; int wsize = 100; for (int i = 0; i < rows; i++) { try { wsize = (Integer) tableWindowSize.getValueAt(i, 0); coverage = (Double) tableWindowSize.getValueAt(i, 1); } catch (NullPointerException e) { //Ignore: cell value is null ; } } for (int i = 0; i < siblings.length; i++) { allTraces[i] = ((TracePanel) siblings[i]).getTrace(); if (allTraces[i].hasNegativeValues()) { posNeg = allTraces[i].splitPositiveNegative(); xyBoundsPositive = Plotter.arrayToSeries(posNeg[0].getDynamicBound(coverage, wsize), allTraces[i].getName(), wsize - 1); xyBoundsNegative = Plotter.arrayToSeriesInvert(posNeg[1].getDynamicBound(coverage, wsize), allTraces[i].getName() + "(neg)", wsize - 1); dataset.addSeries(xyBoundsPositive); dataset.addSeries(xyBoundsNegative); } else { dataset.addSeries(Plotter.arrayToSeries(allTraces[i].getDynamicBound(coverage, wsize), allTraces[i].getName(), wsize - 1)); } } // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart("Comparative Plot (c=" + coverage + ",w=" + wsize + ")", // Title "Time Point", // x-axis Labels "Value", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); chart.setBackgroundPaint(Color.WHITE); chart.getXYPlot().setBackgroundPaint(ChartColor.VERY_LIGHT_YELLOW); chart.getXYPlot().setBackgroundAlpha(0.05f); chart.getXYPlot().setRangeGridlinePaint(Color.LIGHT_GRAY); chart.getXYPlot().setDomainGridlinePaint(Color.LIGHT_GRAY); chart.getTitle().setFont(new Font("Dialog", Font.BOLD, 14)); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setDrawSeriesLineAsPath(true); chart.getXYPlot().setRenderer(renderer); renderer.setSeriesPaint(0, Color.BLACK); renderer.setSeriesPaint(1, ChartColor.DARK_GREEN); renderer.setSeriesPaint(2, ChartColor.DARK_BLUE); renderer.setSeriesPaint(3, ChartColor.RED); int nSeries = chart.getXYPlot().getSeriesCount(); for (int i = 0; i < nSeries; i++) { renderer.setSeriesShapesVisible(i, false); } if (posNeg != null) { renderer.setSeriesVisibleInLegend(5, false); renderer.setSeriesPaint(5, renderer.getSeriesPaint(4)); } // Stroke plainStroke = new BasicStroke( // 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f // ); // // renderer.setSeriesStroke(0, plainStroke); // renderer.setSeriesStroke(1, // new BasicStroke( // 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f // )); // renderer.setSeriesStroke(2, // new BasicStroke( // 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 3.0f, 0.5f, 3.0f }, 0.0f // )); // renderer.setSeriesStroke(3, // new BasicStroke( // 1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 3.0f }, 0.0f // )); JPanel plotPanel = new ChartPanel(chart); JFrame plotFrame = new JFrame(); plotFrame.add(plotPanel); plotFrame.setVisible(true); plotFrame.pack(); plotFrame.setTitle(TracePanel.this.trace.getName()); plotFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); }
From source file:com.headswilllol.basiclauncher.Launcher.java
public void paintComponent(Graphics g) { super.paintComponent(g); g.setFont(font);//from ww w . j a v a 2s . co m if (updateMsg != null) { g.drawString("Update Available!", centerText(g, "Update Available!"), 50); g.setFont(smallFont); g.drawString(updateMsg, centerText(g, updateMsg), 100); } else if (progress == null) g.drawString(NAME + " Launcher", centerText(g, NAME + " Launcher"), 50); else { g.drawString(progress, centerText(g, progress), height / 2); if (fail != null) g.drawString(fail, centerText(g, fail), height / 2 + 50); else { if (aSize != -1 && eSize != -1) { String s = (aSize * 8) + "/" + (int) (eSize * 8) + " B"; if (eSize * 8 >= 1024) if (eSize * 8 >= 1024 * 1024) s = String.format("%.2f", aSize * 8 / 1024 / 1024) + "/" + String.format("%.2f", eSize * 8 / 1024 / 1024) + " MiB"; else s = String.format("%.2f", aSize * 8 / 1024) + "/" + String.format("%.2f", eSize * 8 / 1024) + " KiB"; g.drawString(s, centerText(g, s), height / 2 + 40); String sp = "@" + (int) speed + " B/s"; if (speed >= 1024) if (speed >= 1024 * 1024) sp = "@" + String.format("%.2f", (speed / 1024 / 1024)) + " MiB/s"; else sp = "@" + String.format("%.2f", (speed / 1024)) + " KiB/s"; g.drawString(sp, centerText(g, sp), height / 2 + 80); int barWidth = 500; int barHeight = 35; g.setColor(Color.LIGHT_GRAY); g.drawRect(width / 2 - barWidth / 2, height / 2 + 100, barWidth, barHeight); g.setColor(Color.GREEN); g.fillRect(width / 2 - barWidth / 2 + 1, height / 2 + 100 + 1, (int) ((aSize / eSize) * (double) barWidth - 2), barHeight - 1); g.setColor(new Color(.2f, .2f, .2f)); int percent = (int) (aSize / (double) eSize * 100); g.drawString(percent + "%", centerText(g, percent + "%"), height / 2 + 128); } } } }
From source file:com.rapidminer.gui.plotter.charts.Abstract2DChartPlotter.java
@Override public void updatePlotter() { prepareData();//from w w w . j a va2 s . co m JFreeChart chart; if (axis[X_AXIS] >= 0 && axis[Y_AXIS] >= 0) { if (nominal) { int size = dataSet.getSeriesCount(); chart = ChartFactory.createScatterPlot(null, // chart title null, // domain axis label null, // range axis label dataSet, // data PlotOrientation.VERTICAL, // orientation colorColumn >= 0 && size < 100 ? true : false, // include legend true, // tooltips false // URLs ); // renderer settings try { chart.getXYPlot().setRenderer(getItemRenderer(nominal, size, this.minColor, this.maxColor)); } catch (Exception e) { // do nothing } // 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); BlockContainer wrapper = new BlockContainer(new BorderArrangement()); LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn), new Font("SansSerif", Font.BOLD, 12)); title.setPadding(0, 5, 5, 5); wrapper.add(title, RectangleEdge.LEFT); BlockContainer items = legend.getItemContainer(); wrapper.add(items, RectangleEdge.RIGHT); legend.setWrapper(wrapper); } } else { 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 ); // renderer settings try { chart.getXYPlot().setRenderer(getItemRenderer(nominal, -1, minColor, maxColor)); } catch (Exception e) { // do nothing } LegendTitle legendTitle = new LegendTitle(chart.getXYPlot().getRenderer()) { private static final long serialVersionUID = 1288380309936848376L; @Override public Object draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area, java.lang.Object params) { if (dataTable.isDate(colorColumn) || dataTable.isTime(colorColumn) || dataTable.isDateTime(colorColumn)) { drawSimpleDateLegend(g2, (int) (area.getCenterX() - 170), (int) (area.getCenterY() + 7), dataTable, colorColumn, minColor, maxColor); return new BlockResult(); } else { final String minColorString = Tools.formatNumber(minColor); final String maxColorString = Tools.formatNumber(maxColor); drawSimpleNumericalLegend(g2, (int) (area.getCenterX() - 75), (int) (area.getCenterY() + 7), getDataTable().getColumnName(colorColumn), minColorString, maxColorString); return new BlockResult(); } } @Override public void draw(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D area) { draw(g2, area, null); } }; BlockContainer wrapper = new BlockContainer(new BorderArrangement()); LabelBlock title = new LabelBlock(getDataTable().getColumnName(colorColumn), new Font("SansSerif", Font.BOLD, 12)); title.setPadding(0, 5, 5, 5); wrapper.add(title, RectangleEdge.LEFT); BlockContainer items = legendTitle.getItemContainer(); wrapper.add(items, RectangleEdge.RIGHT); legendTitle.setWrapper(wrapper); chart.addLegend(legendTitle); } } else { 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 ); } // GENERAL CHART SETTINGS // 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 (axis[X_AXIS] >= 0) { if (dataTable.isNominal(axis[X_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[X_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[X_AXIS], i); } plot.setDomainAxis(new SymbolAxis(dataTable.getColumnName(axis[X_AXIS]), values)); } else if (dataTable.isDate(axis[X_AXIS]) || dataTable.isDateTime(axis[X_AXIS])) { DateAxis domainAxis = new DateAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setDomainAxis(domainAxis); } else { if (logScales[X_AXIS]) { LogAxis domainAxis = new LogAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setDomainAxis(domainAxis); } else { NumberAxis domainAxis = new NumberAxis(dataTable.getColumnName(axis[X_AXIS])); domainAxis.setAutoRangeStickyZero(false); domainAxis.setAutoRangeIncludesZero(false); plot.setDomainAxis(domainAxis); } } } if (axis[X_AXIS] >= 0) { Range range = getRangeForDimension(axis[X_AXIS]); if (range != null) { plot.getDomainAxis().setRange(range, true, false); } else { plot.getDomainAxis().setAutoRange(true); } } 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 if (axis[Y_AXIS] >= 0) { if (dataTable.isNominal(axis[Y_AXIS])) { String[] values = new String[dataTable.getNumberOfValues(axis[Y_AXIS])]; for (int i = 0; i < values.length; i++) { values[i] = dataTable.mapIndex(axis[Y_AXIS], i); } plot.setRangeAxis(new SymbolAxis(dataTable.getColumnName(axis[Y_AXIS]), values)); } else if (dataTable.isDate(axis[Y_AXIS]) || dataTable.isDateTime(axis[Y_AXIS])) { DateAxis rangeAxis = new DateAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setTimeZone(Tools.getPreferredTimeZone()); plot.setRangeAxis(rangeAxis); } else { if (logScales[Y_AXIS]) { LogAxis rangeAxis = new LogAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits(Locale.US)); plot.setRangeAxis(rangeAxis); } else { NumberAxis rangeAxis = new NumberAxis(dataTable.getColumnName(axis[Y_AXIS])); rangeAxis.setAutoRangeStickyZero(false); rangeAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(rangeAxis); } } } plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD); plot.getRangeAxis().setTickLabelFont(LABEL_FONT); if (axis[Y_AXIS] >= 0) { Range range = getRangeForDimension(axis[Y_AXIS]); if (range != null) { plot.getRangeAxis().setRange(range, true, false); } else { plot.getRangeAxis().setAutoRange(true); } } // Chart Panel Settings AbstractChartPanel panel = getPlotterPanel(); if (panel == null) { panel = createPanel(chart); // react to mouse clicks panel.addChartMouseListener(new ChartMouseListener() { @Override public void chartMouseClicked(ChartMouseEvent e) { if (e.getTrigger().getClickCount() > 1) { if (e.getEntity() instanceof XYItemEntity) { 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) { } }); } else { panel.setChart(chart); } // tooltips class CustomXYToolTipGenerator implements XYToolTipGenerator { public CustomXYToolTipGenerator() { } private String formatValue(int axis, double value) { if (dataTable.isNominal(axis)) { // TODO add mapping of value to nominal value return Tools.formatIntegerIfPossible(value); } else if (dataTable.isNumerical(axis)) { return Tools.formatIntegerIfPossible(value); } else if (dataTable.isDate(axis)) { return Tools.createDateAndFormat(value); } else if (dataTable.isTime(axis)) { return Tools.createTimeAndFormat(value); } else if (dataTable.isDateTime(axis)) { return Tools.createDateTimeAndFormat(value); } return "?"; } @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) + ", " + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", " + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>"; } else { return "<html>(" + dataset.getSeriesKey(row) + ", " + formatValue(axis[X_AXIS], dataset.getXValue(row, column)) + ", " + formatValue(axis[Y_AXIS], dataset.getYValue(row, column)) + ")</html>"; } } } for (int i = 0; i < dataSet.getSeriesCount(); i++) { plot.getRenderer().setSeriesToolTipGenerator(i, new CustomXYToolTipGenerator()); } }
From source file:charts.Chart.java
public static Vector MultipleStepChartOverlayed(CategoryDataset[] datasets1, CategoryDataset[] datasets2, String title, String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue, float minvalue, boolean showchart) { CategoryAxis domainAxis = new CategoryAxis(x_axis_label); ValueAxis rangeAxis = new NumberAxis(y_axis_label); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); //if (minvalue == 0 && maxvalue == 0) { // rangeAxis.setAutoRange(true); //} else {// www . jav a 2 s. c o m // rangeAxis.setRange(minvalue, maxvalue); //} rangeAxis.setAutoRange(true); CombinedDomainCategoryPlot parent = new CombinedDomainCategoryPlot(new CategoryAxis(x_axis_label)); for (int i = 0; i < datasets1.length; i++) { CategoryItemRenderer renderer1 = new CategoryStepRenderer(true); renderer1.setBaseStroke(new BasicStroke(2.0f)); renderer1.setBaseSeriesVisibleInLegend(showlegend); CategoryPlot subplot = new CategoryPlot(datasets1[i], domainAxis, rangeAxis, renderer1); subplot.setBackgroundPaint(Color.white); subplot.setRangeGridlinePaint(Color.black); subplot.setDomainGridlinesVisible(true); DefaultCategoryItemRenderer renderer2 = new DefaultCategoryItemRenderer(); renderer2.setSeriesPaint(0, Color.LIGHT_GRAY); renderer2.setBaseStroke(new BasicStroke(2.0f)); renderer2.setShapesVisible(true); renderer2.setBaseSeriesVisibleInLegend(false); subplot.setDataset(1, datasets2[i]); subplot.setRenderer(1, renderer2); //subplot.setDrawSharedDomainAxis(true); parent.add(subplot, 1); } JFreeChart jfreechart = new JFreeChart(title, parent); JPanel jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight)); //if (showchart) { JFrame chartwindow = new JFrame(title); chartwindow.setContentPane(jpanel); chartwindow.pack(); RefineryUtilities.centerFrameOnScreen(chartwindow); chartwindow.setVisible(true); //} Vector res = new Vector(); res.add(0, jfreechart); res.add(1, chartwindow); return res; }
From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java
@Override public Component getComponent() { if (dockableComponent == null) { JScrollPane scrollPane = new ExtendedJScrollPane(this); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(null);/*from ww w . j ava 2 s . c o m*/ dockableComponent = new JPanel(new BorderLayout()); JPanel toolBarPanel = new JPanel(new BorderLayout()); ViewToolBar toolBar = new ViewToolBar(); JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton(); toggleExpertModeButton.setText(null); toolBar.add(toggleExpertModeButton); showHelpAction.setSelected(isShowParameterHelp()); JToggleButton helpToggleButton = showHelpAction.createToggleButton(); helpToggleButton.setText(null); toolBar.add(helpToggleButton); Action infoOperatorAction = new InfoOperatorAction() { private static final long serialVersionUID = 6758272768665592429L; @Override protected Operator getOperator() { return mainFrame.getFirstSelectedOperator(); } }; toolBar.add(infoOperatorAction); JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions()) .createToggleButton(); enableOperatorButton.setText(null); toolBar.add(enableOperatorButton); Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") { { setCondition(OPERATOR_SELECTED, MANDATORY); } private static final long serialVersionUID = -3104160320178045540L; @Override public void actionPerformed(ActionEvent e) { Operator operator = mainFrame.getFirstSelectedOperator(); String name = SwingTools.showInputDialog("rename_operator", operator.getName()); if (name != null && name.length() > 0) { operator.rename(name); } } }; toolBar.add(renameOperatorAction); toolBar.add(new DeleteOperatorAction()); breakpointButton.addToToolBar(toolBar); // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION); toolBarPanel.add(toolBar, BorderLayout.NORTH); JPanel headerPanel = new JPanel(); headerPanel.setBackground(SwingTools.LIGHTEST_BLUE); headerPanel.add(headerLabel); headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY)); toolBarPanel.add(headerPanel, BorderLayout.SOUTH); dockableComponent.add(toolBarPanel, BorderLayout.NORTH); dockableComponent.add(scrollPane, BorderLayout.CENTER); // compatibility level and warnings JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(expertModeHintLabel, BorderLayout.CENTER); compatibilityLabel.setLabelFor(compatibilityLevelSpinner); compatibilityLevelSpinner.setPreferredSize( new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight())); compatibilityPanel.add(compatibilityLabel); compatibilityPanel.add(compatibilityLevelSpinner); southPanel.add(compatibilityPanel, BorderLayout.SOUTH); dockableComponent.add(southPanel, BorderLayout.SOUTH); } return dockableComponent; }
From source file:net.sf.taverna.t2.activities.spreadsheet.views.SpreadsheetImportConfigView.java
@Override protected void initialise() { super.initialise(); newConfiguration = getJson().deepCopy(); // title/*w w w. j ava2 s . c o m*/ titlePanel = new JPanel(new BorderLayout()); titlePanel.setBackground(Color.WHITE); addDivider(titlePanel, SwingConstants.BOTTOM, true); titleLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.panelTitle")); titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f)); titleIcon = new JLabel(""); titleMessage = new DialogTextArea(DEFAULT_MESSAGE); titleMessage.setMargin(new Insets(5, 10, 10, 10)); // titleMessage.setMinimumSize(new Dimension(0, 30)); titleMessage.setFont(titleMessage.getFont().deriveFont(11f)); titleMessage.setEditable(false); titleMessage.setFocusable(false); // titleMessage.setFont(titleLabel.getFont().deriveFont(Font.PLAIN, // 12f)); // column range columnLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnSectionLabel")); JsonNode columnRange = newConfiguration.get("columnRange"); columnFromValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("start").intValue()), 4); columnFromValue.setMinimumSize(columnFromValue.getPreferredSize()); columnToValue = new JTextField(new UpperCaseDocument(), SpreadsheetUtils.getColumnLabel(columnRange.get("end").intValue()), 4); columnToValue.setMinimumSize(columnToValue.getPreferredSize()); columnFromValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(columnFromValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(columnFromValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } else if (text.trim().matches("[A-Za-z]+")) { String fromColumn = columnFromValue.getText().toUpperCase(); String toColumn = columnToValue.getText().toUpperCase(); int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn); int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn); if (checkColumnRange(fromColumnIndex, toColumnIndex)) { columnMappingTableModel.setFromColumn(fromColumnIndex); columnMappingTableModel.setToColumn(toColumnIndex); newConfiguration.set("columnRange", newConfiguration.objectNode() .put("start", fromColumnIndex).put("end", toColumnIndex)); validatePortNames(); } removeErrorMessage(FROM_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } else { addErrorMessage(FROM_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_COLUMN_ERROR_MESSAGE); } } }); columnToValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(columnToValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(columnToValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } else if (text.trim().matches("[A-Za-z]+")) { String fromColumn = columnFromValue.getText().toUpperCase(); String toColumn = columnToValue.getText().toUpperCase(); int fromColumnIndex = SpreadsheetUtils.getColumnIndex(fromColumn); int toColumnIndex = SpreadsheetUtils.getColumnIndex(toColumn); if (checkColumnRange(fromColumnIndex, toColumnIndex)) { columnMappingTableModel.setFromColumn(fromColumnIndex); columnMappingTableModel.setToColumn(toColumnIndex); newConfiguration.set("columnRange", newConfiguration.objectNode() .put("start", fromColumnIndex).put("end", toColumnIndex)); validatePortNames(); } removeErrorMessage(TO_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } else { addErrorMessage(TO_COLUMN_ERROR_MESSAGE); removeErrorMessage(EMPTY_TO_COLUMN_ERROR_MESSAGE); } } }); // row range rowLabel = new JLabel(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.rowSectionLabel")); addDivider(rowLabel, SwingConstants.TOP, false); rowSelectAllOption = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.selectAllRowsOption")); rowExcludeFirstOption = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.excludeHeaderRowOption")); rowIgnoreBlankRows = new JCheckBox( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.ignoreBlankRowsOption")); rowSelectAllOption.setFocusable(false); rowExcludeFirstOption.setFocusable(false); JsonNode rowRange = newConfiguration.get("rowRange"); rowFromValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("start").intValue() + 1), 4); if (rowRange.get("end").intValue() == -1) { rowToValue = new JTextField(new NumericDocument(), "", 4); } else { rowToValue = new JTextField(new NumericDocument(), String.valueOf(rowRange.get("end").intValue() + 1), 4); } rowFromValue.setMinimumSize(rowFromValue.getPreferredSize()); rowToValue.setMinimumSize(rowToValue.getPreferredSize()); if (newConfiguration.get("allRows").booleanValue()) { rowSelectAllOption.setSelected(true); rowFromValue.setEditable(false); rowFromValue.setEnabled(false); rowToValue.setEditable(false); rowToValue.setEnabled(false); } else { rowExcludeFirstOption.setEnabled(false); } rowExcludeFirstOption.setSelected(newConfiguration.get("excludeFirstRow").booleanValue()); rowIgnoreBlankRows.setSelected(newConfiguration.get("ignoreBlankRows").booleanValue()); rowFromValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(rowFromValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(rowFromValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { addErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } else if (text.trim().matches("[1-9][0-9]*")) { checkRowRange(rowFromValue.getText(), rowToValue.getText()); int fromRow = Integer.parseInt(rowFromValue.getText()); ((ObjectNode) newConfiguration.get("rowRange")).put("start", fromRow - 1); removeErrorMessage(FROM_ROW_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } else { addErrorMessage(FROM_ROW_ERROR_MESSAGE); removeErrorMessage(EMPTY_FROM_ROW_ERROR_MESSAGE); } } }); rowToValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { checkValue(rowToValue.getText()); } public void removeUpdate(DocumentEvent e) { checkValue(rowToValue.getText()); } private void checkValue(String text) { if (text.trim().equals("")) { ((ObjectNode) newConfiguration.get("rowRange")).put("end", -1); removeErrorMessage(TO_ROW_ERROR_MESSAGE); removeErrorMessage(INCONSISTENT_ROW_MESSAGE); } else if (text.trim().matches("[0-9]+")) { checkRowRange(rowFromValue.getText(), rowToValue.getText()); int toRow = Integer.parseInt(rowToValue.getText()); ((ObjectNode) newConfiguration.get("rowRange")).put("end", toRow - 1); removeErrorMessage(TO_ROW_ERROR_MESSAGE); } else { addErrorMessage(TO_ROW_ERROR_MESSAGE); } } }); rowSelectAllOption.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { newConfiguration.put("allRows", true); rowExcludeFirstOption.setEnabled(true); if (rowExcludeFirstOption.isSelected()) { rowFromValue.setText("2"); } else { rowFromValue.setText("1"); } rowToValue.setText(""); rowFromValue.setEditable(false); rowFromValue.setEnabled(false); rowToValue.setEditable(false); rowToValue.setEnabled(false); } else { newConfiguration.put("allRows", false); rowExcludeFirstOption.setEnabled(false); rowFromValue.setEditable(true); rowFromValue.setEnabled(true); rowToValue.setEditable(true); rowToValue.setEnabled(true); } } }); rowExcludeFirstOption.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { newConfiguration.put("excludeFirstRow", true); rowFromValue.setText("2"); ((ObjectNode) newConfiguration.get("rowRange")).put("start", 1); } else { newConfiguration.put("excludeFirstRow", false); rowFromValue.setText("1"); ((ObjectNode) newConfiguration.get("rowRange")).put("start", 0); } } }); rowIgnoreBlankRows.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { newConfiguration.put("ignoreBlankRows", e.getStateChange() == ItemEvent.SELECTED); } }); // empty cells emptyCellLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyCellSectionLabel")); addDivider(emptyCellLabel, SwingConstants.TOP, false); emptyCellButtonGroup = new ButtonGroup(); emptyCellEmptyStringOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.emptyStringOption")); emptyCellUserDefinedOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedOption")); emptyCellErrorValueOption = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.generateErrorOption")); emptyCellEmptyStringOption.setFocusable(false); emptyCellUserDefinedOption.setFocusable(false); emptyCellErrorValueOption.setFocusable(false); emptyCellUserDefinedValue = new JTextField(newConfiguration.get("emptyCellValue").textValue()); emptyCellButtonGroup.add(emptyCellEmptyStringOption); emptyCellButtonGroup.add(emptyCellUserDefinedOption); emptyCellButtonGroup.add(emptyCellErrorValueOption); if (newConfiguration.get("emptyCellPolicy").textValue().equals("GENERATE_ERROR")) { emptyCellErrorValueOption.setSelected(true); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } else if (newConfiguration.get("emptyCellPolicy").textValue().equals("EMPTY_STRING")) { emptyCellEmptyStringOption.setSelected(true); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } else { emptyCellUserDefinedOption.setSelected(true); emptyCellUserDefinedValue.setText(newConfiguration.get("emptyCellValue").textValue()); emptyCellUserDefinedValue.setEnabled(true); emptyCellUserDefinedValue.setEditable(true); } emptyCellEmptyStringOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "EMPTY_STRING"); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } }); emptyCellUserDefinedOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "USER_DEFINED"); emptyCellUserDefinedValue.setEnabled(true); emptyCellUserDefinedValue.setEditable(true); emptyCellUserDefinedValue.requestFocusInWindow(); } }); emptyCellErrorValueOption.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newConfiguration.put("emptyCellPolicy", "GENERATE_ERROR"); emptyCellUserDefinedValue.setEnabled(false); emptyCellUserDefinedValue.setEditable(false); } }); emptyCellUserDefinedValue.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } public void insertUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } public void removeUpdate(DocumentEvent e) { newConfiguration.put("emptyCellValue", emptyCellUserDefinedValue.getText()); } }); // column mappings columnMappingLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.columnMappingSectionLabel")); addDivider(columnMappingLabel, SwingConstants.TOP, false); Map<String, String> columnToPortMapping = new HashMap<>(); if (newConfiguration.has("columnNames")) { for (JsonNode columnName : newConfiguration.get("columnNames")) { columnToPortMapping.put(columnName.get("column").textValue(), columnName.get("port").textValue()); } } columnMappingTableModel = new SpreadsheetImportConfigTableModel(columnFromValue.getText(), columnToValue.getText(), columnToPortMapping); columnMappingTable = new JTable(); columnMappingTable.setRowSelectionAllowed(false); columnMappingTable.getTableHeader().setReorderingAllowed(false); columnMappingTable.setGridColor(Color.LIGHT_GRAY); // columnMappingTable.setFocusable(false); columnMappingTable.setColumnModel(new DefaultTableColumnModel() { public TableColumn getColumn(int columnIndex) { TableColumn column = super.getColumn(columnIndex); if (columnIndex == 0) { column.setMaxWidth(100); } return column; } }); TableCellEditor defaultEditor = columnMappingTable.getDefaultEditor(String.class); if (defaultEditor instanceof DefaultCellEditor) { DefaultCellEditor defaultCellEditor = (DefaultCellEditor) defaultEditor; defaultCellEditor.setClickCountToStart(1); Component editorComponent = defaultCellEditor.getComponent(); if (editorComponent instanceof JTextComponent) { final JTextComponent textField = (JTextComponent) editorComponent; textField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { updateModel(textField.getText()); } public void insertUpdate(DocumentEvent e) { updateModel(textField.getText()); } public void removeUpdate(DocumentEvent e) { updateModel(textField.getText()); } private void updateModel(String text) { int row = columnMappingTable.getEditingRow(); int column = columnMappingTable.getEditingColumn(); columnMappingTableModel.setValueAt(text, row, column); ArrayNode columnNames = newConfiguration.arrayNode(); Map<String, String> columnToPortMapping = columnMappingTableModel.getColumnToPortMapping(); for (Entry<String, String> entry : columnToPortMapping.entrySet()) { columnNames.add(newConfiguration.objectNode().put("column", entry.getKey()).put("port", entry.getValue())); } newConfiguration.put("columnNames", columnNames); validatePortNames(); } }); } } columnMappingTable.setModel(columnMappingTableModel); // output format outputFormatLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.outputFormatSectionLabel")); outputFormatMultiplePort = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.multiplePortOption")); outputFormatSinglePort = new JRadioButton( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.singlePortOption")); outputFormatMultiplePort.setFocusable(false); outputFormatSinglePort.setFocusable(false); outputFormatDelimiterLabel = new JLabel( SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.userDefinedCsvDelimiter")); outputFormatDelimiter = new JTextField(newConfiguration.get("csvDelimiter").textValue(), 5); outputFormatButtonGroup = new ButtonGroup(); outputFormatButtonGroup.add(outputFormatMultiplePort); outputFormatButtonGroup.add(outputFormatSinglePort); if (newConfiguration.get("outputFormat").textValue().equals("PORT_PER_COLUMN")) { outputFormatMultiplePort.setSelected(true); outputFormatDelimiterLabel.setEnabled(false); outputFormatDelimiter.setEnabled(false); } else { outputFormatSinglePort.setSelected(true); columnMappingLabel.setEnabled(false); enableTable(columnMappingTable, false); } outputFormatMultiplePort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { outputFormatDelimiterLabel.setEnabled(false); outputFormatDelimiter.setEnabled(false); columnMappingLabel.setEnabled(true); enableTable(columnMappingTable, true); newConfiguration.put("outputFormat", "PORT_PER_COLUMN"); } }); outputFormatSinglePort.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { outputFormatDelimiterLabel.setEnabled(true); outputFormatDelimiter.setEnabled(true); columnMappingLabel.setEnabled(false); enableTable(columnMappingTable, false); newConfiguration.put("outputFormat", "SINGLE_PORT"); } }); outputFormatDelimiter.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { handleUpdate(); } public void insertUpdate(DocumentEvent e) { handleUpdate(); } public void removeUpdate(DocumentEvent e) { handleUpdate(); } private void handleUpdate() { String text = null; try { text = StringEscapeUtils.unescapeJava(outputFormatDelimiter.getText()); } catch (RuntimeException re) { } if (text == null || text.length() == 0) { newConfiguration.put("csvDelimiter", ","); } else { newConfiguration.put("csvDelimiter", text.substring(0, 1)); } } }); // buttons nextButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.nextButton")); nextButton.setFocusable(false); nextButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { backButton.setVisible(true); nextButton.setVisible(false); cardLayout.last(contentPanel); } }); backButton = new JButton(SpreadsheetImportUIText.getString("SpreadsheetImportConfigView.backButton")); backButton.setFocusable(false); backButton.setVisible(false); backButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextButton.setVisible(true); backButton.setVisible(false); cardLayout.first(contentPanel); } }); buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); addDivider(buttonPanel, SwingConstants.TOP, true); removeAll(); layoutPanel(); }
From source file:com.diversityarrays.kdxplore.KDXploreFrame.java
private Component makeComponentForTab(KdxApp kdxApp, Component uiComponent) { Component appComponent = uiComponent; DevelopmentState devState = kdxApp.getDevelopmentState(); if (devState.getShouldShowHeading()) { JLabel heading = new JLabel(devState.getHeadingText(), JLabel.CENTER); heading.setOpaque(true);//w w w. ja v a 2s . co m heading.setForeground(devState.getHeadingFontColor()); heading.setBackground(Color.LIGHT_GRAY); heading.setFont(heading.getFont().deriveFont(Font.BOLD)); JPanel p = new JPanel(new BorderLayout()); p.add(heading, BorderLayout.NORTH); //Color.DARK_GRAY, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY // p.add(GuiUtil.createLabelSeparator(devState.getHeadingText(), fontColor, Font.BOLD, Color.LIGHT_GRAY, Color.GRAY), // BorderLayout.NORTH); p.add(uiComponent, BorderLayout.CENTER); appComponent = p; } return appComponent; }
From source file:org.genedb.jogra.plugins.TermRationaliser.java
private Box createRationaliserPanel(final String name, final RationaliserJList rjlist) { int preferredHeight = 500; //change accordingly int preferredWidth = 500; Toolkit tk = Toolkit.getDefaultToolkit(); Dimension size = tk.getScreenSize(); int textboxHeight = 10; //change accordingly int textboxWidth = size.width; Box box = Box.createVerticalBox(); box.add(new JLabel(name)); JTextField searchField = new JTextField(20); //Search field on top /* We don't want this textfield's height to expand when * the Rationaliser is dragged to exapnd. So we set it's * height to what we want and the width to the width of * the screen //w w w .j a v a 2 s . c om */ searchField.setMaximumSize(new Dimension(textboxWidth, textboxHeight)); rjlist.installJTextField(searchField); box.add(searchField); JScrollPane scrollPane = new JScrollPane(); //scroll pane scrollPane.setViewportView(rjlist); scrollPane.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); box.add(scrollPane); TitledBorder sysidBorder = BorderFactory.createTitledBorder("Systematic IDs"); //systematic ID box sysidBorder.setTitleColor(Color.DARK_GRAY); final JTextArea idField = new JTextArea(1, 1); idField.setMaximumSize(new Dimension(textboxWidth, textboxHeight)); idField.setEditable(false); idField.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); idField.setForeground(Color.DARK_GRAY); JScrollPane scroll = new JScrollPane(idField); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); Box sysidBox = Box.createVerticalBox(); sysidBox.add(scroll /*idField*/); sysidBox.setBorder(sysidBorder); box.add(sysidBox); rjlist.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Term highlightedTerm = (Term) rjlist.getSelectedValue(); if (highlightedTerm != null) { /* For each list, call the relevant methods * to get the systematic IDs. Then for the * right list, add the term name in the * text box below */ if (name.equals(FROM_LIST_NAME)) { idField.setText(StringUtils.collectionToCommaDelimitedString( termService.getSystematicIDs(highlightedTerm, selectedTaxons))); } else if (name.equals(TO_LIST_NAME)) { idField.setText(StringUtils.collectionToCommaDelimitedString( termService.getSystematicIDs(highlightedTerm, null))); /* We allow the user to edit the term name */ textField.setText(highlightedTerm.getName()); } } } }); return box; }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
/** * *///from w ww .ja v a 2 s .c om 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()); // Set the meter's range if (range != null) { 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; }