/** * Compares this tick unit to an arbitrary object. * * @param object the object to compare against. * * @return <code>1</code> if the size of the other object is less than this, * <code>0</code> if both have the same size and <code>-1</code> this * size is less than the others. */ public int compareTo(Object object) { if (object instanceof TickUnit) { TickUnit other = (TickUnit) object; if (this.size > other.getSize()) { return 1; } else if (this.size < other.getSize()) { return -1; } else { return 0; } } else { return -1; } }
/** * Compares this tick unit to an arbitrary object. * * @param object the object to compare against. * * @return {@code 1} if the size of the other object is less than this, * {@code 0} if both have the same size and {@code -1} this * size is less than the others. */ @Override public int compareTo(Object object) { if (object instanceof TickUnit) { TickUnit other = (TickUnit) object; if (this.size > other.getSize()) { return 1; } else if (this.size < other.getSize()) { return -1; } else { return 0; } } else { return -1; } }
@Override public TickUnit getCeilingTickUnit(TickUnit unit) { return getCeilingTickUnit(unit.getSize()); }
/** * Returns a tick unit that is larger than the supplied unit. * * @param unit the unit ({@code null} not permitted). * * @return A tick unit that is larger than the supplied unit. */ @Override public TickUnit getLargerTickUnit(TickUnit unit) { double x = unit.getSize(); double log = Math.log(x) / LOG_10_VALUE; double higher = Math.ceil(log); return new NumberTickUnit(Math.pow(10, higher), new DecimalFormat("0.0E0")); }
/** * Returns a tick unit that is larger than the supplied unit. * * @param unit the unit (<code>null</code> not permitted). * * @return A tick unit that is larger than the supplied unit. */ public TickUnit getLargerTickUnit(TickUnit unit) { double x = unit.getSize(); double log = Math.log(x) / LOG_10_VALUE; double higher = Math.ceil(log); return new NumberTickUnit(Math.pow(10, higher), new DecimalFormat("0.0E0")); }
/** * Standard constructor - constructs a panel for editing the properties of * the specified plot. * * @param plot the plot, which should be changed. */ public DefaultPolarPlotEditor(PolarPlot plot) { super(plot); this.angleOffsetValue = plot.getAngleOffset(); this.angleOffset.setText(Double.toString(this.angleOffsetValue)); this.manualTickUnitValue = plot.getAngleTickUnit().getSize(); this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); }
/** * Generates a list of tick values for the angular tick marks. * * @return A list of {@link NumberTick} instances. * * @since 1.0.10 */ protected List refreshAngleTicks() { List ticks = new ArrayList(); for (double currentTickVal = 0.0; currentTickVal < 360.0; currentTickVal += this.angleTickUnit.getSize()) { NumberTick tick = new NumberTick(new Double(currentTickVal), this.angleTickUnit.valueToString(currentTickVal), TextAnchor.CENTER, TextAnchor.CENTER, 0.0); ticks.add(tick); } return ticks; }
/** * Generates a list of tick values for the angular tick marks. * * @return A list of {@link NumberTick} instances. * * @since 1.0.10 */ protected List refreshAngleTicks() { List ticks = new ArrayList(); for (double currentTickVal = 0.0; currentTickVal < 360.0; currentTickVal += this.angleTickUnit.getSize()) { TextAnchor ta = calculateTextAnchor(currentTickVal); NumberTick tick = new NumberTick(new Double(currentTickVal), this.angleTickUnit.valueToString(currentTickVal), ta, TextAnchor.CENTER, 0.0); ticks.add(tick); } return ticks; }
int count = (int) (length / unit.getSize()); if (count < 2 || count > 40) { unit = tickUnitSource.getCeilingTickUnit(length / 20); double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge); double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnitSource.getCeilingTickUnit(guess);
/** * Selects an appropriate tick size for the axis. The strategy is to * display as many ticks as possible (selected from a collection of * 'standard' tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double zero = valueToJava2D(0.0, dataArea, edge); double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double x1 = valueToJava2D(unit1.getSize(), dataArea, edge); double unit1Width = Math.abs(x1 - zero); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess); double x2 = valueToJava2D(unit2.getSize(), dataArea, edge); double unit2Width = Math.abs(x2 - zero); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (DateTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); }
double x1 = valueToJava2D(shift + unit1.getSize(), dataArea, edge); double unit1Width = Math.abs(x1 - zero); double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess); double x2 = valueToJava2D(shift + unit2.getSize(), dataArea, edge);
/** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area in which the plot should be drawn. * @param edge the axis location. */ protected void selectVerticalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelHeight = estimateMaximumTickLabelHeight(g2); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unitHeight = lengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelHeight / unitHeight) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); double unit2Height = lengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelHeight = estimateMaximumTickLabelHeight(g2); if (tickLabelHeight > unit2Height) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); }
double size = tu.getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue();
double size = tu.getSize(); int count = calculateVisibleTickCount(); double lowestTickValue = calculateLowestVisibleTickValue();
/** * Selects an appropriate tick value for the axis. The strategy is to * display as many ticks as possible (selected from an array of 'standard' * tick units) without the labels overlapping. * * @param g2 the graphics device. * @param dataArea the area defined by the axes. * @param edge the axis location. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // start with the current tick unit... TickUnitSource tickUnits = getStandardTickUnits(); TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); double unit1Width = lengthToJava2D(unit1.getSize(), dataArea, edge); // then extrapolate... double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit( guess); double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge); tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); if (tickLabelWidth > unit2Width) { unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); } setTickUnit(unit2, false, false); }
candidate); double candidateWidth = exponentLengthToJava2D(candidate.getSize(), dataArea, edge); if (tickLabelWidth < candidateWidth) {
double tickLabelHeight = estimateMaximumTickLabelHeight(g2); double candidateHeight = exponentLengthToJava2D(candidate.getSize(), dataArea, edge); if (tickLabelHeight < candidateHeight) {