List of usage examples for org.jfree.ui TextAnchor CENTER_RIGHT
TextAnchor CENTER_RIGHT
To view the source code for org.jfree.ui TextAnchor CENTER_RIGHT.
Click Source Link
From source file:com.epiq.bitshark.ui.PowerAxis.java
/** * //w w w . j a va 2s .c o m * @param g2 * @param state * @param dataArea * @param edge * @return */ @Override public List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge) { List<NumberTick> tickList = new ArrayList<NumberTick>(); for (int i = -50; i < 180; i += 10) { tickList.add(new NumberTick(new Double(i), String.format("%d dB", (int) Math.round(valueToDb(i))), TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, 0)); } return tickList; }
From source file:inflor.core.plots.CategoricalNumberAxis.java
@Override public List<NumberTick> refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List<NumberTick> ticks = new ArrayList<>(); for (Entry<Integer, String> entry : labelMap.entrySet()) { ticks.add(new NumberTick(entry.getKey(), entry.getValue(), TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, 0));//from ww w. j a v a 2 s . com } return ticks; }
From source file:org.neo4j.bench.chart.JFreeBarChart.java
@Override protected JFreeChart createChart(AbstractDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Performance chart", "Bench case", "Time(s)", (DefaultCategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false); rotateCategoryAxis(chart, Math.PI / 4.0); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setItemLabelGenerator(new CategoryItemLabelGenerator() { public String generateColumnLabel(CategoryDataset dataset, int column) { return "col" + column; }//from w w w. j a va2 s. c om public String generateLabel(CategoryDataset dataset, int row, int column) { return "" + dataset.getValue(row, column).intValue(); } public String generateRowLabel(CategoryDataset dataset, int row) { return "row" + row; } }); renderer.setBaseItemLabelPaint(Color.black); renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12, TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0)); renderer.setItemLabelsVisible(true); return chart; }
From source file:com.epiq.bitshark.ui.FrequencyAxis.java
/** * /* w w w. j a va 2 s .co m*/ * @param g2 * @param state * @param dataArea * @param edge * @return */ @Override public List refreshTicks(java.awt.Graphics2D g2, AxisState state, java.awt.geom.Rectangle2D dataArea, org.jfree.ui.RectangleEdge edge) { List<NumberTick> tickList = new ArrayList<NumberTick>(); // start tickList.add(new NumberTick(0, toMhzString(center - (rate / 2.0)), TextAnchor.CENTER_LEFT, TextAnchor.CENTER, 0)); // half down tickList.add(new NumberTick((FMCUartClient.BLOCK_SIZE - 1) * .25, toMhzString(center - (rate / 4.0)), TextAnchor.CENTER, TextAnchor.CENTER, 0)); // center tickList.add(new NumberTick((FMCUartClient.BLOCK_SIZE - 1) * .5, toMhzString(center), TextAnchor.CENTER, TextAnchor.CENTER, 0)); // half up tickList.add(new NumberTick((FMCUartClient.BLOCK_SIZE - 1) * .75, toMhzString(center + (rate / 4.0)), TextAnchor.CENTER, TextAnchor.CENTER, 0)); // end tickList.add(new NumberTick(FMCUartClient.BLOCK_SIZE - 1, toMhzString(center + (rate / 2.0)), TextAnchor.CENTER_RIGHT, TextAnchor.CENTER, 0)); return tickList; }
From source file:org.jstockchart.axis.TimeseriesNumberAxis.java
public List<Tick> refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { TextAnchor anchor = null;// ww w.ja v a 2s .c om TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } return createTicks(logicTicks, anchor, rotationAnchor, angle); }
From source file:org.jfree.chart.demo.SurveyResultsDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, categorydataset, PlotOrientation.HORIZONTAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); TextTitle texttitle = new TextTitle( "Figure 7 | I. Resources - The site offers users relevant, informative and educational resources"); texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT); texttitle.setBackgroundPaint(Color.red); texttitle.setPaint(Color.white); jfreechart.setTitle(texttitle);/*from w w w . java2s. c o m*/ CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setOutlinePaint(null); categoryplot.setDomainGridlinesVisible(true); categoryplot.setDomainGridlinePosition(CategoryAnchor.END); categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F)); categoryplot.setDomainGridlinePaint(Color.black); categoryplot.setRangeGridlinesVisible(false); categoryplot.clearRangeMarkers(); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setVisible(false); categoryaxis.setCategoryMargin(0.5D); categoryplot.getRangeAxis().setVisible(false); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setSeriesPaint(0, new Color(156, 164, 74)); barrenderer.setDrawBarOutline(false); barrenderer.setBaseItemLabelsVisible(true); barrenderer.setBaseItemLabelFont(new Font("SansSerif", 1, 10)); ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); barrenderer.setBasePositiveItemLabelPosition(itemlabelposition); CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("1. White papers are available.", "Category 1", 0.0D); categorytextannotation.setFont(new Font("SansSerif", 1, 12)); categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation); CategoryTextAnnotation categorytextannotation1 = new CategoryTextAnnotation( "2. White papers enhance users understanding of the firm and its expertise.", "Category 2", 0.0D); categorytextannotation1.setFont(new Font("SansSerif", 0, 12)); categorytextannotation1.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation1.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation1); CategoryTextAnnotation categorytextannotation2 = new CategoryTextAnnotation( "3. White papers are relevant to the firm's prospects and clients.", "Category 3", 0.0D); categorytextannotation2.setFont(new Font("SansSerif", 0, 12)); categorytextannotation2.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation2.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation2); CategoryTextAnnotation categorytextannotation3 = new CategoryTextAnnotation( "4. White papers are relevant to the firm's positioning.", "Category 4", 0.0D); categorytextannotation3.setFont(new Font("SansSerif", 0, 12)); categorytextannotation3.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation3.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation3); CategoryTextAnnotation categorytextannotation4 = new CategoryTextAnnotation( "5. Case studies are available.", "Category 5", 0.0D); categorytextannotation4.setFont(new Font("SansSerif", 1, 12)); categorytextannotation4.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation4.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation4); CategoryTextAnnotation categorytextannotation5 = new CategoryTextAnnotation( "6. Case studies enhance users understanding of the firm and its expertise.", "Category 6", 0.0D); categorytextannotation5.setFont(new Font("SansSerif", 0, 12)); categorytextannotation5.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation5.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation5); CategoryTextAnnotation categorytextannotation6 = new CategoryTextAnnotation( "7. Case studies are relevant to the firm's prospects and clients.", "Category 7", 0.0D); categorytextannotation6.setFont(new Font("SansSerif", 0, 12)); categorytextannotation6.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation6.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation6); CategoryTextAnnotation categorytextannotation7 = new CategoryTextAnnotation( "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0D); categorytextannotation7.setFont(new Font("SansSerif", 0, 12)); categorytextannotation7.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation7.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation7); CategoryTextAnnotation categorytextannotation8 = new CategoryTextAnnotation( "9. Case studies are available.", "Category 9", 0.0D); categorytextannotation8.setFont(new Font("SansSerif", 1, 12)); categorytextannotation8.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation8.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation8); CategoryTextAnnotation categorytextannotation9 = new CategoryTextAnnotation( "10. Case studies enhance users understanding of the firm and its expertise.", "Category 10", 0.0D); categorytextannotation9.setFont(new Font("SansSerif", 0, 12)); categorytextannotation9.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation9.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation9); CategoryTextAnnotation categorytextannotation10 = new CategoryTextAnnotation( "11. Case studies are relevant to the firm's prospects and clients.", "Category 11", 0.0D); categorytextannotation10.setFont(new Font("SansSerif", 0, 12)); categorytextannotation10.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation10.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation10); CategoryTextAnnotation categorytextannotation11 = new CategoryTextAnnotation( "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0D); categorytextannotation11.setFont(new Font("SansSerif", 0, 12)); categorytextannotation11.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation11.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation11); CategoryTextAnnotation categorytextannotation12 = new CategoryTextAnnotation( "13. Users can easily access resources based on viewer interest.", "Category 13", 0.0D); categorytextannotation12.setFont(new Font("SansSerif", 1, 12)); categorytextannotation12.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation12.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation12); CategoryTextAnnotation categorytextannotation13 = new CategoryTextAnnotation( "14. Access to additional hyperlinks enhances users's ability to find relevant information.", "Category 14", 0.0D); categorytextannotation13.setFont(new Font("SansSerif", 1, 12)); categorytextannotation13.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation13.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation13); CategoryTextAnnotation categorytextannotation14 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.", "Overall", 0.0D); categorytextannotation14.setFont(new Font("SansSerif", 1, 12)); categorytextannotation14.setTextAnchor(TextAnchor.BOTTOM_LEFT); categorytextannotation14.setCategoryAnchor(CategoryAnchor.START); categoryplot.addAnnotation(categorytextannotation14); return jfreechart; }
From source file:org.jstockchart.axis.TimeseriesDateAxis.java
public List<Tick> refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { TextAnchor anchor = null;/* ww w . j av a 2s . c o m*/ TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; if (edge == RectangleEdge.TOP) { angle = Math.PI / 2.0; } else { angle = -Math.PI / 2.0; } } else { if (edge == RectangleEdge.TOP) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; } else { anchor = TextAnchor.TOP_CENTER; rotationAnchor = TextAnchor.TOP_CENTER; } } return createTicksHorizontal(logicTicks, anchor, rotationAnchor, angle); }
From source file:edu.jhuapl.graphs.jfreechart.utils.RotatedTickDateAxis.java
@SuppressWarnings("unchecked") @Override//w ww. ja v a 2s. c o m protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double rotationAngleInRad = Math.toRadians(tickLabelAngle); //Template types are specified here for additional type safety. List<Tick> ticks = (List<Tick>) super.refreshTicksHorizontal(g2, dataArea, edge); List<Tick> ret = new ArrayList<Tick>(); for (Tick tick : ticks) { if (tick instanceof DateTick) { DateTick dateTick = (DateTick) tick; //The anchor used depends on the label angle, as follows: TextAnchor textAnchor, rotationAnchor; double modRadians = rotationAngleInRad % (2 * Math.PI); //Handle case where user provided a negative angle value. if (modRadians < 0) { modRadians += 2 * Math.PI; } //For angles between 0-180 degrees: if (modRadians <= Math.PI) { textAnchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } //For angles between 180-360 degrees: else { textAnchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } ret.add(new DateTick(dateTick.getDate(), dateTick.getText(), textAnchor, rotationAnchor, rotationAngleInRad)); } else { ret.add(tick); } } return ret; }
From source file:org.jstockchart.axis.TimeseriesNumberAxis.java
public List<Tick> refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { TextAnchor anchor = null;//from www. j a va 2s.c om TextAnchor rotationAnchor = null; double angle = 0.0; if (isVerticalTickLabels()) { anchor = TextAnchor.BOTTOM_CENTER; rotationAnchor = TextAnchor.BOTTOM_CENTER; if (edge == RectangleEdge.LEFT) { angle = -Math.PI / 2.0; } else { angle = Math.PI / 2.0; } } else { if (edge == RectangleEdge.LEFT) { anchor = TextAnchor.CENTER_RIGHT; rotationAnchor = TextAnchor.CENTER_RIGHT; } else { anchor = TextAnchor.CENTER_LEFT; rotationAnchor = TextAnchor.CENTER_LEFT; } } return createTicks(logicTicks, anchor, rotationAnchor, angle); }
From source file:org.jstockchart.axis.TimeseriesDateAxis.java
private static TextAnchor adjustAnchorHorizontal(TextAnchor anchor, TickAlignment alignment) { TextAnchor result = null;// w ww.ja v a 2 s . co m if (alignment.equals(TickAlignment.MID)) { result = anchor; } else if (alignment.equals(TickAlignment.START)) { if (anchor.equals(TextAnchor.CENTER_RIGHT)) { result = TextAnchor.CENTER_RIGHT; } else if (anchor.equals(TextAnchor.BOTTOM_CENTER)) { result = TextAnchor.BOTTOM_LEFT; } else if (anchor.equals(TextAnchor.TOP_CENTER)) { result = TextAnchor.TOP_LEFT; } else { result = anchor; } } else if (alignment.equals(TickAlignment.END)) { if (anchor.equals(TextAnchor.CENTER_RIGHT)) { result = TextAnchor.CENTER_RIGHT; } else if (anchor.equals(TextAnchor.BOTTOM_CENTER)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(TextAnchor.TOP_CENTER)) { result = TextAnchor.TOP_RIGHT; } else { result = anchor; } } return result; }