List of usage examples for org.jfree.chart.axis NumberAxis getLabelFont
public Font getLabelFont()
From source file:com.hazelcast.monitor.server.MChartGenerator.java
@Override protected void afterPlot(List<? super InstanceStatistics> list, JFreeChart chart, XYPlot plot) { NumberAxis sizeAxis = (NumberAxis) plot.getRangeAxis(0); Font labelFont = sizeAxis.getLabelFont(); Paint labelPaint = sizeAxis.getLabelPaint(); TimeSeries tm = new TimeSeries("memory"); for (int i = 0; i < list.size(); i++) { double memory = 0; MapStatistics mapStatistics = (MapStatistics) list.get(i); for (MapStatistics.LocalMapStatistics localMapStatistics : mapStatistics.getListOfLocalStats()) { memory = memory + localMapStatistics.ownedEntryMemoryCost + localMapStatistics.backupEntryMemoryCost + localMapStatistics.markedAsRemovedMemoryCost; }/*from w w w .ja va 2 s . c om*/ double mem = new Double(memory / (double) (1024 * 1024)); tm.addOrUpdate(new Second(((MapStatistics) list.get(i)).getCreatedDate()), mem); } NumberAxis memoryAxis = new NumberAxis("memory (MB)"); memoryAxis.setAutoRange(true); memoryAxis.setAutoRangeIncludesZero(false); plot.setDataset(1, new TimeSeriesCollection(tm)); plot.setRangeAxis(1, memoryAxis); plot.mapDatasetToRangeAxis(1, 1); plot.setRenderer(1, new StandardXYItemRenderer()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); increaseRange(memoryAxis); memoryAxis.setLabelFont(labelFont); memoryAxis.setLabelPaint(labelPaint); }
From source file:com.chart.SwingChart.java
/** * Add axis// w ww . jav a 2 s.com * @param name new axis name */ @Override public final void addAxis(String name) { boolean encontrado = false; for (AxisChart categoria : axes) { if (categoria.getName().equals(name)) { encontrado = true; break; } } if (!encontrado) { axes.add(new AxisChart((name))); } XYSeriesCollection dataset = new XYSeriesCollection(); NumberAxis ejeOrdenada = new NumberAxis(name); ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); int i = datasetList.size(); datasetList.add(dataset); AxesList.add(ejeOrdenada); plot.setDataset(i, dataset); plot.setRangeAxis(i, ejeOrdenada); plot.setRangeAxisLocation(i, AxisLocation.BOTTOM_OR_LEFT); plot.mapDatasetToRangeAxis(i, i); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true); if (i == 0) { plot.setRenderer(renderer); } else { plot.setRenderer(i, renderer); } final LegendAxis le; final int indiceLeyenda = legendFrame.getChildren().size(); legendFrame.getChildren().add(le = new LegendAxis(name)); le.setOnMouseClicked((MouseEvent t) -> { if (le.selected && t.getClickCount() == 2) { setOrdinateRange(AxesList.get(indiceLeyenda)); } }); le.setOnMouseEntered((MouseEvent t) -> { le.setStyle("-fx-background-color:blue"); le.selected = true; AxesList.get(indiceLeyenda).setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web("blue"))); AxesList.get(indiceLeyenda).setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web("blue"))); }); le.setOnMouseExited((MouseEvent t) -> { le.setStyle("-fx-background-color:" + strBackgroundColor); le.selected = false; AxesList.get(indiceLeyenda).setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); AxesList.get(indiceLeyenda) .setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); }); }
From source file:com.chart.SwingChart.java
/** * Background edition// w w w. j av a2 s .c om */ final public void backgroundEdition() { final ColorPicker colorPickerChartBackground = new ColorPicker( javafx.scene.paint.Color.web(strChartBackgroundColor)); colorPickerChartBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerGridline = new ColorPicker(javafx.scene.paint.Color.web(strGridlineColor)); colorPickerGridline.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerBackground = new ColorPicker(javafx.scene.paint.Color.web(strBackgroundColor)); colorPickerBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerTick = new ColorPicker(javafx.scene.paint.Color.web(strTickColor)); colorPickerTick.setMaxWidth(Double.MAX_VALUE); final TextField tfFontSize = new TextField(); tfFontSize.setMaxWidth(Double.MAX_VALUE); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Background color"), 0, 0); grid.add(colorPickerChartBackground, 1, 0); grid.add(new Label("Gridline color"), 0, 1); grid.add(colorPickerGridline, 1, 1); grid.add(new Label("Frame color"), 0, 2); grid.add(colorPickerBackground, 1, 2); grid.add(new Label("Tick color"), 0, 3); grid.add(colorPickerTick, 1, 3); grid.add(new Label("Font size"), 0, 4); grid.add(tfFontSize, 1, 4); tfFontSize.setText(String.valueOf(fontSize)); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { fontSize = Float.valueOf(tfFontSize.getText().replace(",", ".")); strBackgroundColor = colorPickerBackground.getValue().toString().replace("0x", "#"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder( scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + colorPickerBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: marco;"); strChartBackgroundColor = colorPickerChartBackground.getValue().toString().replace("0x", "#"); plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn).setStyle("fondo: " + colorPickerChartBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = colorPickerGridline.getValue().toString().replace("0x", "#"); plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = colorPickerTick.getValue().toString().replace("0x", "#"); abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); } return true; } }.show(); }
From source file:org.forester.archaeopteryx.TreePanel.java
private static JFreeChart createChart(CategoryDataset dataset, String branch_name) { // create the chart JFreeChart chart = ChartFactory.createBarChart("RAxML Weights Histogram " + branch_name, // chart title "RAxML Weights", // domain axis label "Placements", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? );/* ww w. j av a 2 s .co m*/ // set the background color for the chart and title colors & font chart.setBackgroundPaint(Color.black); chart.setTextAntiAlias(true); chart.setBorderPaint(Color.green); chart.getTitle().setPaint(Color.white); chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(12.0f)); // get a reference to the plot for further customisation CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(0.7f); plot.setBackgroundPaint(Color.black); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only, set colors & font final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelPaint(Color.white); rangeAxis.setLabelFont(rangeAxis.getLabelFont().deriveFont(10.0f)); rangeAxis.setAxisLinePaint(new Color(226, 236, 243)); rangeAxis.setTickLabelFont(rangeAxis.getTickLabelFont().deriveFont(8.0f)); rangeAxis.setTickLabelPaint(Color.white); // Custom renderer to display each bar in another color final BarRenderer renderer = new CustomRenderer(new Paint[] { new Color(255, 0, 0), new Color(227, 28, 0), new Color(199, 56, 0), new Color(171, 84, 0), new Color(143, 112, 0), new Color(115, 140, 0), new Color(87, 168, 0), new Color(59, 196, 0), new Color(31, 224, 0), new Color(0, 255, 0) }); // shadow effect off renderer.setShadowVisible(false); //make custom renderer the new renderer for the barchart plot.setRenderer(renderer); // set x axis label rotation, font and color CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4)); domainAxis.setLabelPaint(Color.white); domainAxis.setLabelFont(domainAxis.getLabelFont().deriveFont(10.0f)); domainAxis.setTickLabelPaint(Color.white); domainAxis.setTickLabelFont(domainAxis.getTickLabelFont().deriveFont(8.0f)); domainAxis.setAxisLinePaint(new Color(226, 236, 243)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }