List of usage examples for org.jfree.ui RectangleAnchor BOTTOM
RectangleAnchor BOTTOM
To view the source code for org.jfree.ui RectangleAnchor BOTTOM.
Click Source Link
From source file:com.ivli.roim.controls.DomainMarker.java
public void setLinkedMarker(ValueMarker aM) { iLink = aM;/*from w ww . j av a 2s. co m*/ iLink.setValue(XYSeriesUtilities.getNearestY(iSeries, getValue())); iLink.setLabelAnchor(RectangleAnchor.BOTTOM); iLink.setLabelOffset(RectangleInsets.ZERO_INSETS); }
From source file:storybook.ui.chart.jfreechart.ChartUtil.java
public static Marker getDateMarker(Date paramDate, String paramString, boolean paramBoolean) { double d = paramDate.getTime(); ValueMarker localValueMarker = new ValueMarker(d, Color.red, new BasicStroke(0.3F)); localValueMarker.setLabel(paramString); localValueMarker.setLabelFont(new Font("SansSerif", 2, 11)); localValueMarker.setLabelAnchor(RectangleAnchor.BOTTOM); if (paramBoolean) { localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } else {/* w w w. j a v a 2 s .co m*/ localValueMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } return localValueMarker; }
From source file:storybook.ui.chart.jfreechart.ChartUtil.java
public static Marker getDateIntervalMarker(Date paramDate1, Date paramDate2, String paramString) { double d1 = paramDate1.getTime(); double d2 = paramDate2.getTime(); BasicStroke localBasicStroke = new BasicStroke(0.3F); IntervalMarker localIntervalMarker = new IntervalMarker(d1, d2, Color.pink, localBasicStroke, Color.black, localBasicStroke, 0.5F);/*from ww w. ja v a 2 s. co m*/ localIntervalMarker.setLabel(paramString); localIntervalMarker.setLabelAnchor(RectangleAnchor.BOTTOM); localIntervalMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); return localIntervalMarker; }
From source file:com.appnativa.rare.ui.chart.jfreechart.ChartHelper.java
public static RectangleAnchor getRectangleAnchor(ChartDataItem item) { RectangleAnchor ta;//from w w w. j a v a 2 s . co m switch (item.getIconPosition()) { case LEADING: case LEFT: ta = RectangleAnchor.LEFT; break; case TRAILING: case RIGHT: ta = RectangleAnchor.RIGHT; break; case TOP_CENTER: ta = RectangleAnchor.TOP; break; case BOTTOM_CENTER: ta = RectangleAnchor.BOTTOM; break; default: ta = RectangleAnchor.CENTER; break; } return ta; }
From source file:nl.vu.nat.jfreechartcustom.XYBlockRenderer.java
/** * Updates the offsets to take into account the block width, height and * anchor./* w w w . j a v a 2 s .c o m*/ */ private void updateOffsets() { if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { this.xOffset = 0.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { this.xOffset = 0.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { this.xOffset = -this.blockWidth / 2.0; this.yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { this.xOffset = -this.blockWidth; this.yOffset = -this.blockHeight; } }
From source file:com.griddynamics.jagger.monitoring.reporting.SystemUnderTestPlotsGeneralProvider.java
public Map<String, List<MonitoringReporterData>> createTaskPlots() { log.info("BEGIN: Create general task plots"); Map<String, List<MonitoringReporterData>> taskPlots = new LinkedHashMap<String, List<MonitoringReporterData>>(); GeneralStatistics generalStatistics = getStatistics(); Set<String> taskIds = generalStatistics.findTaskIds(); Set<String> boxIdentifiers = generalStatistics.findBoxIdentifiers(); Set<String> sutUrls = generalStatistics.findSutUrls(); for (GroupKey groupName : plotGroups.getPlotGroups().keySet()) { log.info(" Create general task plots for group '{}'", groupName); if (showPlotsByGlobal) { log.info(" Create general global task plots"); List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>(); XYSeriesCollection chartsCollection = new XYSeriesCollection(); LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>(); for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) { log.info(" Create general global task plots for parameter '{}'", parameterId); MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId); if (generalStatistics.hasGlobalStatistics(param)) { XYSeries values = new XYSeries(param.getDescription()); long timeShift = 0; int taskNum = 0; for (String taskId : taskIds) { log.info(" Create general global task plots for task '{}'", taskId); long maxTime = 0; for (MonitoringStatistics monitoringStatistics : generalStatistics .findGlobalStatistics(taskId, param)) { long time = monitoringStatistics.getTime(); double t = timeShift + time; values.add(t, monitoringStatistics.getAverageValue()); if (time > maxTime) { maxTime = time; }/*from www. j a v a2s. c o m*/ if (showNumbers) { IntervalMarker marker = markers.get(taskId); if (marker == null) { marker = new IntervalMarker(t, t); marker.setLabel(monitoringStatistics.getTaskData().getNumber().toString()); marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f); int mod = taskNum % 3; if (mod == 0) { marker.setLabelAnchor(RectangleAnchor.CENTER); } else if (mod == 1) { marker.setLabelAnchor(RectangleAnchor.TOP); } else if (mod == 2) { marker.setLabelAnchor(RectangleAnchor.BOTTOM); } marker.setLabelFont( marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD)); markers.put(taskId, marker); } else { if (t < marker.getStartValue()) { marker.setStartValue(t); } if (t > marker.getEndValue()) { marker.setEndValue(t); } } } } timeShift += maxTime; taskNum++; } if (values.isEmpty()) { values.add(0, 0); } chartsCollection.addSeries(values); } } log.debug("group name \n{} \nparams {}]\n", groupName, Lists.newArrayList(plotGroups.getPlotGroups().get(groupName))); Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection, markers.values()); chartsCollection = pair.getSecond(); String name = groupName.getUpperName(); if (chartsCollection.getSeriesCount() > 0) { JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection, "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1, ChartHelper.ColorTheme.LIGHT); XYPlot plot = (XYPlot) chart.getPlot(); for (IntervalMarker marker : markers.values()) { plot.addDomainMarker(marker); } MonitoringReporterData monitoringReporterData = new MonitoringReporterData(); monitoringReporterData.setParameterName(name); monitoringReporterData.setTitle(name); monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart)); plots.add(monitoringReporterData); } if (!plots.isEmpty()) { taskPlots.put(name, plots); } } if (showPlotsByBox) { log.info(" Create general box task plots"); for (String boxIdentifier : boxIdentifiers) { log.info(" Create general box task plots for box '{}'", boxIdentifier); List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>(); XYSeriesCollection chartsCollection = new XYSeriesCollection(); LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>(); for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) { log.info(" Create general box task plots for parameter '{}'", parameterId); MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId); if (generalStatistics.hasBoxStatistics(param, boxIdentifier)) { XYSeries values = new XYSeries(param.getDescription()); long timeShift = 0; int taskNum = 0; for (String taskId : taskIds) { log.info(" Create general box task plots for task '{}'", taskId); long maxTime = 0; for (MonitoringStatistics monitoringStatistics : generalStatistics .findBoxStatistics(taskId, param, boxIdentifier)) { long time = monitoringStatistics.getTime(); double t = timeShift + time; values.add(t, monitoringStatistics.getAverageValue()); if (time > maxTime) { maxTime = time; } if (showNumbers) { IntervalMarker marker = markers.get(taskId); if (marker == null) { marker = new IntervalMarker(t, t); marker.setLabel( monitoringStatistics.getTaskData().getNumber().toString()); marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f); int mod = taskNum % 3; if (mod == 0) { marker.setLabelAnchor(RectangleAnchor.CENTER); } else if (mod == 1) { marker.setLabelAnchor(RectangleAnchor.TOP); } else if (mod == 2) { marker.setLabelAnchor(RectangleAnchor.BOTTOM); } marker.setLabelFont( marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD)); markers.put(taskId, marker); } else { if (t < marker.getStartValue()) { marker.setStartValue(t); } if (t > marker.getEndValue()) { marker.setEndValue(t); } } } } timeShift += maxTime; taskNum++; } if (values.isEmpty()) { values.add(0, 0); } chartsCollection.addSeries(values); } } log.debug("group name \n{} \nparams {}]\n", groupName, Lists.newArrayList(plotGroups.getPlotGroups().get(groupName))); Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection, markers.values()); chartsCollection = pair.getSecond(); String name = groupName.getUpperName() + " on " + boxIdentifier; if (chartsCollection.getSeriesCount() > 0) { JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection, "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1, ChartHelper.ColorTheme.LIGHT); XYPlot plot = (XYPlot) chart.getPlot(); for (IntervalMarker marker : markers.values()) { plot.addDomainMarker(marker); } MonitoringReporterData monitoringReporterData = new MonitoringReporterData(); monitoringReporterData.setParameterName(name); monitoringReporterData.setTitle(name); monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart)); plots.add(monitoringReporterData); } if (!plots.isEmpty()) { taskPlots.put(name, plots); } } } if (showPlotsBySuT) { log.info(" Create general sut task plots"); for (String sutUrl : sutUrls) { log.info(" Create general sut task plots for sut '{}'", sutUrl); List<MonitoringReporterData> plots = new LinkedList<MonitoringReporterData>(); XYSeriesCollection chartsCollection = new XYSeriesCollection(); LinkedHashMap<String, IntervalMarker> markers = new LinkedHashMap<String, IntervalMarker>(); for (MonitoringParameter parameterId : plotGroups.getPlotGroups().get(groupName)) { log.info(" Create general sut task plots for parameter '{}'", parameterId); MonitoringParameterBean param = MonitoringParameterBean.copyOf(parameterId); if (generalStatistics.hasSutStatistics(param, sutUrl)) { XYSeries values = new XYSeries(param.getDescription()); long timeShift = 0; int taskNum = 0; for (String taskId : taskIds) { log.info(" Create general sut task plots for task '{}'", taskId); long maxTime = 0; for (MonitoringStatistics monitoringStatistics : generalStatistics .findSutStatistics(taskId, param, sutUrl)) { long time = monitoringStatistics.getTime(); double t = timeShift + time; values.add(t, monitoringStatistics.getAverageValue()); if (time > maxTime) { maxTime = time; } if (showNumbers) { IntervalMarker marker = markers.get(taskId); if (marker == null) { marker = new IntervalMarker(t, t); marker.setLabel( monitoringStatistics.getTaskData().getNumber().toString()); marker.setAlpha((taskNum % 2 == 0) ? 0.2f : 0.4f); int mod = taskNum % 3; if (mod == 0) { marker.setLabelAnchor(RectangleAnchor.CENTER); } else if (mod == 1) { marker.setLabelAnchor(RectangleAnchor.TOP); } else if (mod == 2) { marker.setLabelAnchor(RectangleAnchor.BOTTOM); } marker.setLabelFont( marker.getLabelFont().deriveFont(10.0f).deriveFont(Font.BOLD)); markers.put(taskId, marker); } else { if (t < marker.getStartValue()) { marker.setStartValue(t); } if (t > marker.getEndValue()) { marker.setEndValue(t); } } } } timeShift += maxTime; taskNum++; } if (values.isEmpty()) { values.add(0, 0); } chartsCollection.addSeries(values); } } log.debug("group name \n{} \nparams {}]\n", groupName, Lists.newArrayList(plotGroups.getPlotGroups().get(groupName))); Pair<String, XYSeriesCollection> pair = ChartHelper.adjustTime(chartsCollection, markers.values()); chartsCollection = pair.getSecond(); String name = groupName.getUpperName() + " on " + sutUrl; if (chartsCollection.getSeriesCount() > 0) { JFreeChart chart = ChartHelper.createXYChart(null, chartsCollection, "Time (" + pair.getFirst() + ")", groupName.getLeftName(), 0, 1, ChartHelper.ColorTheme.LIGHT); XYPlot plot = (XYPlot) chart.getPlot(); for (IntervalMarker marker : markers.values()) { plot.addDomainMarker(marker); } MonitoringReporterData monitoringReporterData = new MonitoringReporterData(); monitoringReporterData.setParameterName(name); monitoringReporterData.setTitle(name); monitoringReporterData.setPlot(new JCommonDrawableRenderer(chart)); plots.add(monitoringReporterData); } if (!plots.isEmpty()) { taskPlots.put(name, plots); } } } } clearStatistics(); log.info("END: Create general task plots"); return taskPlots; }
From source file:anl.verdi.plot.jfree.XYBlockRenderer.java
/** * Updates the offsets to take into account the block width, height and * anchor.// ww w . j av a 2 s. c om */ private void updateOffsets() { if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { xOffset = 0.0; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { xOffset = -this.blockWidth / 2.0; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { xOffset = -this.blockWidth; yOffset = 0.0; } else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { xOffset = 0.0; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { xOffset = -this.blockWidth / 2.0; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { xOffset = -this.blockWidth; yOffset = -this.blockHeight / 2.0; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { xOffset = 0.0; yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { xOffset = -this.blockWidth / 2.0; yOffset = -this.blockHeight; } else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { xOffset = -this.blockWidth; yOffset = -this.blockHeight; } }
From source file:org.fhcrc.cpl.toolbox.gui.chart.PanelWithHeatMap.java
public void setData(double[] xValues, double[] yValues, double[][] zValues) { this.xValues = xValues; this.yValues = yValues; this.zValues = zValues; double minZValue = Double.MAX_VALUE; double maxZValue = Double.MIN_VALUE; int width = xValues.length; int height = yValues.length; int numCells = width * height; _log.debug("Number of cells in heat map: " + numCells); if (zValues.length != width || zValues[0].length != height) throw new RuntimeException( "PanelWithHeatMap: wrong number of z values for x and y values (" + zValues.length + " vs. " + width + ", " + zValues[0].length + " vs. " + height + ", x/y first, z second)"); DefaultXYZDataset theDataset = new DefaultXYZDataset(); double[][] data = new double[3][numCells]; for (int j = 0; j < height; j++) { for (int i = 0; i < width; i++) { int cellIndex = (j * width) + i; data[0][cellIndex] = xValues[i]; data[1][cellIndex] = yValues[j]; data[2][cellIndex] = zValues[i][j]; //keep track of lowest/highest z values minZValue = Math.min(zValues[i][j], minZValue); maxZValue = Math.max(zValues[i][j], maxZValue); }// www.j ava 2s .c om } lowerZBound = Rounder.round(minZValue, 3); upperZBound = Rounder.round(maxZValue, 3); if (lowerZBound == upperZBound) upperZBound += .0001; _log.debug("low,high values: " + lowerZBound + ", " + upperZBound); theDataset.addSeries("Range: " + lowerZBound + "-" + upperZBound, data); dataset = theDataset; if (renderer == null) { renderer = new XYBlockRenderer(); } if (paintScale == null) { setPaintScale(createPaintScale(palette)); } //This is necessary to get everything to line up renderer.setBlockAnchor(RectangleAnchor.BOTTOM); if (getPlot() != null) { ((XYPlot) getPlot()).setDataset(dataset); ((XYPlot) getPlot()).setRenderer(renderer); invalidate(); return; } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(dataSetName, JFreeChart.DEFAULT_TITLE_FONT, plot, true); // chart.addLegend(new LegendTitle(renderer)); // PaintScaleLegend legend = new PaintScaleLegend(paintScale, xAxis); // chart.addLegend(legend); // LegendItemCollection c1 = new LegendItemCollection(); // // LegendItem item1 = new LegendItem("Label", "Description", // "ToolTip", "URL", true, // new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, // true, Color.blue, new BasicStroke(1.2f), true, // new Line2D.Double(1.0, 2.0, 3.0, 4.0), // new BasicStroke(2.1f), Color.green); // LegendItem item2 = new LegendItem("Label", "Description", // "ToolTip", "URL", true, // new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), // true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, // new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), // Color.green); // c1.add(item1); // // chart.getLegend().setSources(new LegendItemSource[]{renderer}); init(chart); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void testCreateUpRotationCategoryLabelPosition() { TestableCategoricalChartExpression e = new TestableCategoricalChartExpression(); {//from ww w. j a v a 2s . c o m CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 0.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, -90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.BOTTOM, 180.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.TOP, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 0.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_RIGHT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_RIGHT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, -90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.LEFT, 180.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.RIGHT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP, 0.0); Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.BOTTOM_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.BOTTOM_CENTER, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.TOP, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.BOTTOM, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, 0.0); Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.CENTER_LEFT, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.CENTER_LEFT, c.getRotationAnchor()); } { CategoryLabelPosition c = e.createUpRotationCategoryLabelPosition(PlaneDirection.RIGHT, 90.0 * Math.PI / 180.0); Assert.assertEquals(RectangleAnchor.LEFT, c.getCategoryAnchor()); Assert.assertEquals(TextBlockAnchor.TOP_CENTER, c.getLabelAnchor()); Assert.assertEquals(TextAnchor.TOP_CENTER, c.getRotationAnchor()); } }
From source file:hr.restart.util.chart.ChartXY.java
/** * Creates a BAR CHART/* w w w .ja v a2 s .co m*/ * @param dataset The org.jfree.data.CategoryDataset * @param title The title * @return org.jfree.chart.JFreeChart */ private JFreeChart createBarChart(final CategoryDataset dataset, String title, PlotOrientation orientation) { final JFreeChart chart = ChartFactory.createBarChart(title, // chart title "", // domain axis label "", // range axis label dataset, // data orientation, // the plot orientation false, // include legend true, false); chart.setBackgroundPaint(Color.white); // the subtitle from the combobox if (jcb != null) chart.addSubtitle(new TextTitle(jcb.getSelectedItem().toString())); //subtitles setted by the user. if (getSubtitles() != null) for (int i = 0; i < getSubtitles().size(); i++) { chart.addSubtitle(new TextTitle(getSubtitles().get(i).toString())); } final Plot plot = chart.getPlot(); // get a reference to the plot for further customisation... final CategoryPlot categoryPlot = (CategoryPlot) plot; categoryPlot.setNoDataMessage("NO DATA!"); categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }); categoryPlot.setRenderer(renderer); renderer.setLabelGenerator(new StandardCategoryLabelGenerator()); renderer.setItemLabelsVisible(true); // inside //renderer.setBaseItemLabelPaint(Color.white); Font font = new Font("SansSerif", Font.PLAIN, 7); Font derive = font.deriveFont(Font.BOLD); renderer.setBaseItemLabelFont(derive); // margin final CategoryAxis domainAxis = categoryPlot.getDomainAxis(); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); //domainAxis.setBottomCategoryLabelPosition(new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER)); domainAxis.setCategoryLabelPositions(new CategoryLabelPositions( new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER), // TOP new CategoryLabelPosition(RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER), // BOTTOM new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, CategoryLabelWidthType.RANGE, 0.30f), // LEFT new CategoryLabelPosition(RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT, CategoryLabelWidthType.RANGE, 0.30f) // RIGHT) )); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, TextAnchor.CENTER, 0.0); renderer.setPositiveItemLabelPosition(p); if (comboBoxOrientation != null) { if (comboBoxOrientation.getSelectedItem() == "Vertikalni") { domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)); } } return chart; }