public double getMajorTickMarkDistance() { return (getMaxValue() - getMinValue()) / (getNumMajorTicks() - 1); }
public String[] createTickmarkTexts() { double roundFactor = MathUtils.computeRoundFactor(getMinValue(), getMaxValue(), 3); return createTickmarkTexts(getMinValue(), getMaxValue(), getNumMajorTicks(), roundFactor); }
public void resetMinMaxAccumulatorsFromAxes() { xMinAccum = getXAxis().getMinValue(); xMaxAccum = getXAxis().getMaxValue(); yMinAccum = getYAxis().getMinValue(); yMaxAccum = getYAxis().getMaxValue(); }
private void validate(Graphics2D g2d, int x, int y, int width, int height) { fontMetrics = g2d.getFontMetrics(); xTickTexts = xAxis.createTickmarkTexts(); yTickTexts = yAxis.createTickmarkTexts(); // define y-Axis _values final int fontAscent = fontMetrics.getAscent(); maxYTickTextWidth = 0; for (String yTickText : yTickTexts) { int sw = fontMetrics.stringWidth(yTickText); maxYTickTextWidth = Math.max(maxYTickTextWidth, sw); } final int widthMaxX = fontMetrics.stringWidth(xTickTexts[xTickTexts.length - 1]); int x1 = textGap + fontAscent + textGap + maxYTickTextWidth + textGap + majorTickLength; int y1 = textGap + fontAscent / 2; int x2 = x + width - (textGap + widthMaxX / 2); int y2 = y + height - (textGap + fontAscent + textGap + fontAscent + textGap + majorTickLength); final int w = x2 - x1 + 1; final int h = y2 - y1 + 1; graphArea = new Rectangle(x1, y1, w, h); transform = null; if (w > 0 && h > 0) { transform = new RectTransform(new Range(xAxis.getMinValue(), xAxis.getMaxValue()), new Range(yAxis.getMinValue(), yAxis.getMaxValue()), new Range(graphArea.x, graphArea.x + graphArea.width), new Range(graphArea.y + graphArea.height, graphArea.y)); } setValid(w > 0 && h > 0); }
public void testSetSubDivision() { diagramAxis.setSubDivision(12.4, 83.6, 7, 4); assertEquals(12.4, diagramAxis.getMinValue(), 1e-9); assertEquals(83.6, diagramAxis.getMaxValue(), 1e-9); assertEquals(7, diagramAxis.getNumMajorTicks()); assertEquals(4, diagramAxis.getNumMinorTicks()); assertEquals(3, eventCounter.counts); }
public void testSetOptimalSubDivision() { diagramAxis.setValueRange(13.1, 16.2); assertEquals(1, eventCounter.counts); diagramAxis.setOptimalSubDivision(4, 6, 8); assertEquals(16.5, diagramAxis.getMaxValue(), 1e-9); assertEquals(12.75, diagramAxis.getMinValue(), 1e-9); assertEquals(6, diagramAxis.getNumMajorTicks()); assertEquals(8, diagramAxis.getNumMinorTicks()); assertEquals(4, eventCounter.counts); }
assertEquals(13.1, diagramAxis.getMinValue(), 1e-9); assertEquals(8, eventCounter.counts);