Java Code Examples for org.jfree.ui.TextAnchor#BOTTOM_CENTER
The following examples show how to use
org.jfree.ui.TextAnchor#BOTTOM_CENTER .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CrosshairOverlay.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.BOTTOM_LEFT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.TOP_RIGHT; } return result; }
Example 2
Source File: CrosshairOverlay.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.BOTTOM_LEFT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.TOP_RIGHT; } return result; }
Example 3
Source File: CrosshairOverlay.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorV(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.TOP_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.BOTTOM_LEFT; } return result; }
Example 4
Source File: Histogram.java From chipster with MIT License | 5 votes |
private void updateHistogram() throws MicroarrayException, IOException { updateChipBox(); int barCount = ((SpinnerNumberModel) barCountSpinner.getModel()).getNumber().intValue(); String expression = ((Variable) chipBox.getSelectedItem()).getExpression(); FloatArrayList histogram = getHistogram(barCount, expression); if (histogram != null) { CategoryDataset dataset = toCategoryDataset(histogram); CategoryAxis categoryAxis = new CategoryAxis("value"); ValueAxis valueAxis = new NumberAxis("count"); BarRenderer renderer = new BarRenderer(); ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); renderer.setBasePositiveItemLabelPosition(position1); ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); renderer.setBaseNegativeItemLabelPosition(position2); CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(data.getName(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); visualisationPanel.removeAll(); visualisationPanel.add(makePanel(chart), BorderLayout.CENTER); visualisationPanel.validate(); } else { throw new IllegalArgumentException("histogram not supported for " + data.getName()); } }
Example 5
Source File: CrosshairOverlay.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorV(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.TOP_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.BOTTOM_LEFT; } return result; }
Example 6
Source File: CrosshairOverlay.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Returns the text anchor that is used to align a label to its anchor * point. * * @param anchor the anchor. * * @return The text alignment point. */ private TextAnchor textAlignPtForLabelAnchorV(RectangleAnchor anchor) { TextAnchor result = TextAnchor.CENTER; if (anchor.equals(RectangleAnchor.TOP_LEFT)) { result = TextAnchor.TOP_RIGHT; } else if (anchor.equals(RectangleAnchor.TOP)) { result = TextAnchor.TOP_CENTER; } else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { result = TextAnchor.TOP_LEFT; } else if (anchor.equals(RectangleAnchor.LEFT)) { result = TextAnchor.HALF_ASCENT_RIGHT; } else if (anchor.equals(RectangleAnchor.RIGHT)) { result = TextAnchor.HALF_ASCENT_LEFT; } else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { result = TextAnchor.BOTTOM_RIGHT; } else if (anchor.equals(RectangleAnchor.BOTTOM)) { result = TextAnchor.BOTTOM_CENTER; } else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { result = TextAnchor.BOTTOM_LEFT; } return result; }
Example 7
Source File: NumberAxis.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the data should be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = getTickUnit().valueToString(currentTickValue); } TextAnchor anchor = null; 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; } } Tick tick = new NumberTick( new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle ); result.add(tick); } } return result; }
Example 8
Source File: DrawStringDemo.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Converts a string to a corresponding {@link TextAnchor} instance. * * @param text the text. * * @return The anchor. */ private TextAnchor convertStringToAnchor(final String text) { if (text.equals("TextAnchor.TOP_LEFT")) { return TextAnchor.TOP_LEFT; } else if (text.equals("TextAnchor.TOP_CENTER")) { return TextAnchor.TOP_CENTER; } else if (text.equals("TextAnchor.TOP_RIGHT")) { return TextAnchor.TOP_RIGHT; } else if (text.equals("TextAnchor.CENTER_LEFT")) { return TextAnchor.CENTER_LEFT; } else if (text.equals("TextAnchor.CENTER")) { return TextAnchor.CENTER; } else if (text.equals("TextAnchor.CENTER_RIGHT")) { return TextAnchor.CENTER_RIGHT; } else if (text.equals("TextAnchor.HALF_ASCENT_LEFT")) { return TextAnchor.HALF_ASCENT_LEFT; } else if (text.equals("TextAnchor.HALF_ASCENT_CENTER")) { return TextAnchor.HALF_ASCENT_CENTER; } else if (text.equals("TextAnchor.HALF_ASCENT_RIGHT")) { return TextAnchor.HALF_ASCENT_RIGHT; } else if (text.equals("TextAnchor.BASELINE_LEFT")) { return TextAnchor.BASELINE_LEFT; } else if (text.equals("TextAnchor.BASELINE_CENTER")) { return TextAnchor.BASELINE_CENTER; } else if (text.equals("TextAnchor.BASELINE_RIGHT")) { return TextAnchor.BASELINE_RIGHT; } else if (text.equals("TextAnchor.BOTTOM_LEFT")) { return TextAnchor.BOTTOM_LEFT; } else if (text.equals("TextAnchor.BOTTOM_CENTER")) { return TextAnchor.BOTTOM_CENTER; } else if (text.equals("TextAnchor.BOTTOM_RIGHT")) { return TextAnchor.BOTTOM_RIGHT; } else { return null; } }
Example 9
Source File: PolarPlot.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Calculate the text position for the given degrees. * * @param angleDegrees the angle in degrees. * * @return The optimal text anchor. * @since 1.0.14 */ protected TextAnchor calculateTextAnchor(double angleDegrees) { TextAnchor ta = TextAnchor.CENTER; // normalize angle double offset = this.angleOffset; while (offset < 0.0) { offset += 360.0; } double normalizedAngle = (((this.counterClockwise ? -1 : 1) * angleDegrees) + offset) % 360; while (this.counterClockwise && (normalizedAngle < 0.0)) { normalizedAngle += 360.0; } if (normalizedAngle == 0.0) { ta = TextAnchor.CENTER_LEFT; } else if (normalizedAngle > 0.0 && normalizedAngle < 90.0) { ta = TextAnchor.TOP_LEFT; } else if (normalizedAngle == 90.0) { ta = TextAnchor.TOP_CENTER; } else if (normalizedAngle > 90.0 && normalizedAngle < 180.0) { ta = TextAnchor.TOP_RIGHT; } else if (normalizedAngle == 180) { ta = TextAnchor.CENTER_RIGHT; } else if (normalizedAngle > 180.0 && normalizedAngle < 270.0) { ta = TextAnchor.BOTTOM_RIGHT; } else if (normalizedAngle == 270) { ta = TextAnchor.BOTTOM_CENTER; } else if (normalizedAngle > 270.0 && normalizedAngle < 360.0) { ta = TextAnchor.BOTTOM_LEFT; } return ta; }
Example 10
Source File: PolarPlot.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Calculate the text position for the given degrees. * * @param angleDegrees the angle in degrees. * * @return The optimal text anchor. * @since 1.0.14 */ protected TextAnchor calculateTextAnchor(double angleDegrees) { TextAnchor ta = TextAnchor.CENTER; // normalize angle double offset = this.angleOffset; while (offset < 0.0) { offset += 360.0; } double normalizedAngle = (((this.counterClockwise ? -1 : 1) * angleDegrees) + offset) % 360; while (this.counterClockwise && (normalizedAngle < 0.0)) { normalizedAngle += 360.0; } if (normalizedAngle == 0.0) { ta = TextAnchor.CENTER_LEFT; } else if (normalizedAngle > 0.0 && normalizedAngle < 90.0) { ta = TextAnchor.TOP_LEFT; } else if (normalizedAngle == 90.0) { ta = TextAnchor.TOP_CENTER; } else if (normalizedAngle > 90.0 && normalizedAngle < 180.0) { ta = TextAnchor.TOP_RIGHT; } else if (normalizedAngle == 180) { ta = TextAnchor.CENTER_RIGHT; } else if (normalizedAngle > 180.0 && normalizedAngle < 270.0) { ta = TextAnchor.BOTTOM_RIGHT; } else if (normalizedAngle == 270) { ta = TextAnchor.BOTTOM_CENTER; } else if (normalizedAngle > 270.0 && normalizedAngle < 360.0) { ta = TextAnchor.BOTTOM_LEFT; } return ta; }
Example 11
Source File: DateAxis.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Recalculates the ticks for the date axis. * * @param g2 the graphics device. * @param dataArea the area in which the data is to be drawn. * @param edge the location of the axis. * * @return A list of ticks. */ protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); if (isAutoTickUnitSelection()) { selectAutoTickUnit(g2, dataArea, edge); } DateTickUnit unit = getTickUnit(); Date tickDate = calculateLowestVisibleTickValue(unit); Date upperDate = getMaximumDate(); // float lastX = Float.MIN_VALUE; while (tickDate.before(upperDate)) { if (!isHiddenValue(tickDate.getTime())) { // work out the value, label and position String tickLabel; DateFormat formatter = getDateFormatOverride(); if (formatter != null) { tickLabel = formatter.format(tickDate); } else { tickLabel = this.tickUnit.dateToString(tickDate); } TextAnchor anchor = null; 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; } } Tick tick = new DateTick( tickDate, tickLabel, anchor, rotationAnchor, angle ); result.add(tick); tickDate = unit.addToDate(tickDate); } else { tickDate = unit.rollDate(tickDate); continue; } // could add a flag to make the following correction optional... switch (unit.getUnit()) { case (DateTickUnit.MILLISECOND) : case (DateTickUnit.SECOND) : case (DateTickUnit.MINUTE) : case (DateTickUnit.HOUR) : case (DateTickUnit.DAY) : break; case (DateTickUnit.MONTH) : tickDate = calculateDateForPosition(new Month(tickDate), this.tickMarkPosition); break; case(DateTickUnit.YEAR) : tickDate = calculateDateForPosition( new Year(tickDate), this.tickMarkPosition); break; default: break; } } return result; }
Example 12
Source File: SymbolAxis.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return The ticks. */ @Override protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); double previousDrawnTickLabelPos = 0.0; double previousDrawnTickLabelLength = 0.0; if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = yy; previousDrawnTickLabelLength = tickLabelLength; } TextAnchor anchor; TextAnchor rotationAnchor; 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; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } return ticks; }
Example 13
Source File: AbstractRenderer.java From opensim-gui with Apache License 2.0 | 4 votes |
/** * Default constructor. */ public AbstractRenderer() { this.seriesVisible = null; this.seriesVisibleList = new BooleanList(); this.baseSeriesVisible = true; this.seriesVisibleInLegend = null; this.seriesVisibleInLegendList = new BooleanList(); this.baseSeriesVisibleInLegend = true; this.paint = null; this.paintList = new PaintList(); this.basePaint = DEFAULT_PAINT; this.fillPaint = null; this.fillPaintList = new PaintList(); this.baseFillPaint = Color.white; this.outlinePaint = null; this.outlinePaintList = new PaintList(); this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT; this.stroke = null; this.strokeList = new StrokeList(); this.baseStroke = DEFAULT_STROKE; this.outlineStroke = null; this.outlineStrokeList = new StrokeList(); this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE; this.shape = null; this.shapeList = new ShapeList(); this.baseShape = DEFAULT_SHAPE; this.itemLabelsVisible = null; this.itemLabelsVisibleList = new BooleanList(); this.baseItemLabelsVisible = Boolean.FALSE; this.itemLabelFont = null; this.itemLabelFontList = new ObjectList(); this.baseItemLabelFont = new Font("SansSerif", Font.PLAIN, 10); this.itemLabelPaint = null; this.itemLabelPaintList = new PaintList(); this.baseItemLabelPaint = Color.black; this.positiveItemLabelPosition = null; this.positiveItemLabelPositionList = new ObjectList(); this.basePositiveItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER ); this.negativeItemLabelPosition = null; this.negativeItemLabelPositionList = new ObjectList(); this.baseNegativeItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER ); this.createEntities = null; this.createEntitiesList = new BooleanList(); this.baseCreateEntities = true; this.listenerList = new EventListenerList(); }
Example 14
Source File: AbstractRenderer.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Default constructor. */ public AbstractRenderer() { this.seriesVisible = null; this.seriesVisibleList = new BooleanList(); this.baseSeriesVisible = true; this.seriesVisibleInLegend = null; this.seriesVisibleInLegendList = new BooleanList(); this.baseSeriesVisibleInLegend = true; this.paint = null; this.paintList = new PaintList(); this.basePaint = DEFAULT_PAINT; this.autoPopulateSeriesPaint = true; this.fillPaint = null; this.fillPaintList = new PaintList(); this.baseFillPaint = Color.white; this.autoPopulateSeriesFillPaint = false; this.outlinePaint = null; this.outlinePaintList = new PaintList(); this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT; this.autoPopulateSeriesOutlinePaint = false; this.stroke = null; this.strokeList = new StrokeList(); this.baseStroke = DEFAULT_STROKE; this.autoPopulateSeriesStroke = true; this.outlineStroke = null; this.outlineStrokeList = new StrokeList(); this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE; this.autoPopulateSeriesOutlineStroke = false; this.shape = null; this.shapeList = new ShapeList(); this.baseShape = DEFAULT_SHAPE; this.autoPopulateSeriesShape = true; this.itemLabelsVisible = null; this.itemLabelsVisibleList = new BooleanList(); this.baseItemLabelsVisible = Boolean.FALSE; this.itemLabelFont = null; this.itemLabelFontMap = new HashMap<Integer, Font>(); this.baseItemLabelFont = new Font("SansSerif", Font.PLAIN, 10); this.itemLabelPaint = null; this.itemLabelPaintList = new PaintList(); this.baseItemLabelPaint = Color.black; this.positiveItemLabelPosition = null; this.positiveItemLabelPositionMap = new HashMap<Integer, ItemLabelPosition>(); this.basePositiveItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); this.negativeItemLabelPosition = null; this.negativeItemLabelPositionMap = new HashMap<Integer, ItemLabelPosition>(); this.baseNegativeItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); this.createEntities = null; this.createEntitiesList = new BooleanList(); this.baseCreateEntities = true; this.defaultEntityRadius = 3; this.legendShapeList = new ShapeList(); this.baseLegendShape = null; this.treatLegendShapeAsLine = false; this.legendTextFontMap = new HashMap<Integer, Font>(); this.baseLegendTextFont = null; this.legendTextPaint = new PaintList(); this.baseLegendTextPaint = null; this.listenerList = new EventListenerList(); }
Example 15
Source File: ItemLabelPosition.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates a new position record with default settings. */ public ItemLabelPosition() { this(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0); }
Example 16
Source File: SymbolAxis.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return The ticks. */ @Override protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); double previousDrawnTickLabelPos = 0.0; double previousDrawnTickLabelLength = 0.0; if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double yy = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getWidth() : bounds.getHeight(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(yy - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = yy; previousDrawnTickLabelLength = tickLabelLength; } TextAnchor anchor; TextAnchor rotationAnchor; 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; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } return ticks; }
Example 17
Source File: SymbolAxis.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Calculates the positions of the tick labels for the axis, storing the * results in the tick label list (ready for drawing). * * @param g2 the graphics device. * @param dataArea the area in which the data should be drawn. * @param edge the location of the axis. * * @return The ticks. */ @Override protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { List ticks = new java.util.ArrayList(); Font tickLabelFont = getTickLabelFont(); g2.setFont(tickLabelFont); double size = getTickUnit().getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue(); double previousDrawnTickLabelPos = 0.0; double previousDrawnTickLabelLength = 0.0; if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { for (int i = 0; i < count; i++) { double currentTickValue = lowestTickValue + (i * size); double xx = valueToJava2D(currentTickValue, dataArea, edge); String tickLabel; NumberFormat formatter = getNumberFormatOverride(); if (formatter != null) { tickLabel = formatter.format(currentTickValue); } else { tickLabel = valueToString(currentTickValue); } // avoid to draw overlapping tick labels Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, g2.getFontMetrics()); double tickLabelLength = isVerticalTickLabels() ? bounds.getHeight() : bounds.getWidth(); boolean tickLabelsOverlapping = false; if (i > 0) { double avgTickLabelLength = (previousDrawnTickLabelLength + tickLabelLength) / 2.0; if (Math.abs(xx - previousDrawnTickLabelPos) < avgTickLabelLength) { tickLabelsOverlapping = true; } } if (tickLabelsOverlapping) { tickLabel = ""; // don't draw this tick label } else { // remember these values for next comparison previousDrawnTickLabelPos = xx; previousDrawnTickLabelLength = tickLabelLength; } TextAnchor anchor; TextAnchor rotationAnchor; 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; } } Tick tick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor, angle); ticks.add(tick); } } return ticks; }
Example 18
Source File: PolarPlot.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Calculate the text position for the given degrees. * * @param angleDegrees the angle in degrees. * * @return The optimal text anchor. * @since 1.0.14 */ protected TextAnchor calculateTextAnchor(double angleDegrees) { TextAnchor ta = TextAnchor.CENTER; // normalize angle double offset = this.angleOffset; while (offset < 0.0) { offset += 360.0; } double normalizedAngle = (((this.counterClockwise ? -1 : 1) * angleDegrees) + offset) % 360; while (this.counterClockwise && (normalizedAngle < 0.0)) { normalizedAngle += 360.0; } if (normalizedAngle == 0.0) { ta = TextAnchor.CENTER_LEFT; } else if (normalizedAngle > 0.0 && normalizedAngle < 90.0) { ta = TextAnchor.TOP_LEFT; } else if (normalizedAngle == 90.0) { ta = TextAnchor.TOP_CENTER; } else if (normalizedAngle > 90.0 && normalizedAngle < 180.0) { ta = TextAnchor.TOP_RIGHT; } else if (normalizedAngle == 180) { ta = TextAnchor.CENTER_RIGHT; } else if (normalizedAngle > 180.0 && normalizedAngle < 270.0) { ta = TextAnchor.BOTTOM_RIGHT; } else if (normalizedAngle == 270) { ta = TextAnchor.BOTTOM_CENTER; } else if (normalizedAngle > 270.0 && normalizedAngle < 360.0) { ta = TextAnchor.BOTTOM_LEFT; } return ta; }
Example 19
Source File: ItemLabelPosition.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates a new position record with default settings. */ public ItemLabelPosition() { this(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, TextAnchor.CENTER, 0.0); }
Example 20
Source File: AbstractRenderer.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Default constructor. */ public AbstractRenderer() { this.seriesVisible = null; this.seriesVisibleList = new BooleanList(); this.baseSeriesVisible = true; this.seriesVisibleInLegend = null; this.seriesVisibleInLegendList = new BooleanList(); this.baseSeriesVisibleInLegend = true; this.paint = null; this.paintList = new PaintList(); this.basePaint = DEFAULT_PAINT; this.autoPopulateSeriesPaint = true; this.fillPaint = null; this.fillPaintList = new PaintList(); this.baseFillPaint = Color.white; this.autoPopulateSeriesFillPaint = false; this.outlinePaint = null; this.outlinePaintList = new PaintList(); this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT; this.autoPopulateSeriesOutlinePaint = false; this.stroke = null; this.strokeList = new StrokeList(); this.baseStroke = DEFAULT_STROKE; this.autoPopulateSeriesStroke = true; this.outlineStroke = null; this.outlineStrokeList = new StrokeList(); this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE; this.autoPopulateSeriesOutlineStroke = false; this.shape = null; this.shapeList = new ShapeList(); this.baseShape = DEFAULT_SHAPE; this.autoPopulateSeriesShape = true; this.itemLabelsVisible = null; this.itemLabelsVisibleList = new BooleanList(); this.baseItemLabelsVisible = Boolean.FALSE; this.itemLabelFont = null; this.itemLabelFontMap = new HashMap<Integer, Font>(); this.baseItemLabelFont = new Font("SansSerif", Font.PLAIN, 10); this.itemLabelPaint = null; this.itemLabelPaintList = new PaintList(); this.baseItemLabelPaint = Color.black; this.positiveItemLabelPosition = null; this.positiveItemLabelPositionMap = new HashMap<Integer, ItemLabelPosition>(); this.basePositiveItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); this.negativeItemLabelPosition = null; this.negativeItemLabelPositionMap = new HashMap<Integer, ItemLabelPosition>(); this.baseNegativeItemLabelPosition = new ItemLabelPosition( ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); this.createEntities = null; this.createEntitiesList = new BooleanList(); this.baseCreateEntities = true; this.defaultEntityRadius = 3; this.legendShapeList = new ShapeList(); this.baseLegendShape = null; this.treatLegendShapeAsLine = false; this.legendTextFontMap = new HashMap<Integer, Font>(); this.baseLegendTextFont = null; this.legendTextPaint = new PaintList(); this.baseLegendTextPaint = null; this.listenerList = new EventListenerList(); }