List of usage examples for org.jfree.ui RectangleAnchor RIGHT
RectangleAnchor RIGHT
To view the source code for org.jfree.ui RectangleAnchor RIGHT.
Click Source Link
From source file:org.jtheque.films.stats.view.impl.panels.PanelStats.java
/** * Create a panel containing a pie chart. * * @param key The i18 key of the title of the pie chart. * @param dataset The dataset used to populate the pie chart. * * @return The component containing the pie chart. *//*from ww w. j a v a2 s . c o m*/ final Component createPieChartPanel(String key, PieDataset dataset) { JFreeChart pie = ChartFactory.createPieChart3D(resources.getMessage(key), dataset, true, true, true); pie.getLegend().setLegendItemGraphicLocation(RectangleAnchor.RIGHT); Managers.getManager(ILanguageManager.class).addInternationalizable(new InternationalizableChart(pie, key)); Component chartPanel = new ChartPanel(pie); chartPanel.setBackground(Color.white); return chartPanel; }
From source file:org.uncommons.watchmaker.swing.evolutionmonitor.JVMView.java
private JFreeChart createHeapChart(double maxMemory) { TimeSeriesCollection dataSet = new TimeSeriesCollection(); dataSet.addSeries(memoryUsageSeries); dataSet.addSeries(heapSizeSeries);/*from ww w.ja v a2s. c om*/ JFreeChart chart = ChartFactory.createXYAreaChart("JVM Heap", "Time", "Megabytes", dataSet, PlotOrientation.VERTICAL, true, // Legend. false, // Tooltips. false); DateAxis timeAxis = new DateAxis("Time"); timeAxis.setLowerMargin(0); timeAxis.setUpperMargin(0); chart.getXYPlot().setDomainAxis(timeAxis); chart.getXYPlot().getRangeAxis().setLowerBound(0); chart.getXYPlot().getRangeAxis().setUpperBound(maxMemory * 1.1); // Add 10% to leave room for marker. // Add a horizontal marker to indicate the heap growth limit. ValueMarker marker = new ValueMarker(maxMemory, Color.BLACK, new BasicStroke(1)); marker.setLabel("Maximum Permitted Heap Size (adjust with -Xmx)"); marker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); marker.setLabelAnchor(RectangleAnchor.RIGHT); chart.getXYPlot().addRangeMarker(marker); chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.RED); chart.getXYPlot().getRenderer().setSeriesPaint(1, new Color(0, 128, 0, 128)); return chart; }
From source file:org.jfree.experimental.chart.plot.dial.DialValueIndicator.java
/** * Creates a new instance of <code>DialValueIndicator</code>. * // w w w .jav a2s .c om * @param datasetIndex the dataset index. * @param label the label. */ public DialValueIndicator(int datasetIndex, String label) { this.datasetIndex = datasetIndex; this.angle = -90.0; this.radius = 0.3; this.frameAnchor = RectangleAnchor.CENTER; this.templateValue = new Double(100.0); this.formatter = new DecimalFormat("0.0"); this.font = new Font("Dialog", Font.BOLD, 14); this.paint = Color.black; this.backgroundPaint = Color.white; this.outlineStroke = new BasicStroke(1.0f); this.outlinePaint = Color.blue; this.insets = new RectangleInsets(4, 4, 4, 4); this.valueAnchor = RectangleAnchor.RIGHT; this.textAnchor = TextAnchor.CENTER_RIGHT; }
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 2s . c o 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.//from w w w . j a v a 2s. co 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:anl.verdi.plot.jfree.XYBlockRenderer.java
/** * Updates the offsets to take into account the block width, height and * anchor.//www .jav a 2 s.c o m */ 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.pentaho.plugin.jfreereport.reportcharts.CategoricalChartExpressionTest.java
@Test public void testCreateUpRotationCategoryLabelPosition() { TestableCategoricalChartExpression e = new TestableCategoricalChartExpression(); {//from w w w.j ava 2 s. 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. j a v a 2s. com * @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; }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
public void addRangeMarker(CategoryPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException { IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd()); rangeMarker.setPaint(convertStringToColor(rmData.getColor())); if (rmData.getLabel() != null) { rangeMarker.setLabel(rmData.getLabel()); rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor())); String labelPos = rmData.getLabelPosition(); if (labelPos.equals("top_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { rangeMarker.setLabelAnchor(RectangleAnchor.LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { rangeMarker.setLabelAnchor(RectangleAnchor.CENTER); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); }//from w w w. j a v a 2s . com rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); rangeMarker.setLabelFont( getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize())); } plot.addRangeMarker(rangeMarker, Layer.BACKGROUND); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
public void addRangeMarker(XYPlot plot, cfCHARTRANGEMARKERData rmData) throws cfmRunTimeException { IntervalMarker rangeMarker = new IntervalMarker(rmData.getStart(), rmData.getEnd()); rangeMarker.setPaint(convertStringToColor(rmData.getColor())); if (rmData.getLabel() != null) { rangeMarker.setLabel(rmData.getLabel()); rangeMarker.setLabelPaint(convertStringToColor(rmData.getLabelColor())); String labelPos = rmData.getLabelPosition(); if (labelPos.equals("top_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { rangeMarker.setLabelAnchor(RectangleAnchor.LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { rangeMarker.setLabelAnchor(RectangleAnchor.CENTER); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { rangeMarker.setLabelAnchor(RectangleAnchor.RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { rangeMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); rangeMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); }//www.j av a 2 s .c o m rangeMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); rangeMarker.setLabelFont( getFont(rmData.getFont(), rmData.getFontBold(), rmData.getFontItalic(), rmData.getFontSize())); } plot.addRangeMarker(rangeMarker, org.jfree.ui.Layer.BACKGROUND); }