/** * Calculates the bar thickness. * * @param plotArea the plot area. * @param edge the location. * * @return The thickness. */ private double calculateBarThickness(Rectangle2D plotArea, RectangleEdge edge) { double result = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { result = plotArea.getWidth() * this.colorBarThicknessPercent; } else { result = plotArea.getHeight() * this.colorBarThicknessPercent; } return result; }
/** * Draws the tick marks for the axis. * * @param g2 the graphics device. * @param state the axis state. * @param dataArea the data area. * @param edge the edge. */ protected void drawTickMarks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { drawTickMarksHorizontal(g2, state, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { drawTickMarksVertical(g2, state, dataArea, edge); } }
float yy = 0.0f; for (int i = 0; i < subCategoryCount; i++) { if (RectangleEdge.isTopOrBottom(edge)) { xx = (float) (x0 + (i + 0.5) * width); yy = (float) area.getCenterY(); if (edge.equals(RectangleEdge.TOP)) { double h = maxdim; state.cursorUp(h); else if (edge.equals(RectangleEdge.BOTTOM)) { double h = maxdim; state.cursorDown(h);
/** * Returns the edge for a domain axis. * * @param index the axis index. * * @return The edge. * * @see #getRangeAxisEdge(int) */ public RectangleEdge getDomainAxisEdge(int index) { AxisLocation location = getDomainAxisLocation(index); RectangleEdge result = Plot.resolveDomainAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getDomainAxisEdge()); } return result; }
double cursor = RectangleEdge.coordinate(dataArea, domainEdge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, domainEdge, info);
g2.setStroke(new BasicStroke(1.0f)); if (RectangleEdge.isTopOrBottom(edge)) { double y1 = colorBarArea.getY(); double y2 = colorBarArea.getMaxY();
/** * 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 selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } }
/** * Returns the edge for a range axis. * * @param index the axis index. * * @return The edge. */ public RectangleEdge getRangeAxisEdge(int index) { AxisLocation location = getRangeAxisLocation(index); RectangleEdge result = Plot.resolveRangeAxisLocation(location, this.orientation); if (result == null) { result = RectangleEdge.opposite(getRangeAxisEdge(0)); } return result; }
double cursor = RectangleEdge.coordinate(dataArea, edge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info);
Rectangle2D r = new Rectangle2D.Double(); if (RectangleEdge.isTopOrBottom(getPosition())) { RectangleEdge axisEdge = Plot.resolveRangeAxisLocation( this.axisLocation, PlotOrientation.HORIZONTAL);
/** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { RectangleEdge result = null; if (this.equals(RectangleEdge.TOP)) { result = RectangleEdge.TOP; } else if (this.equals(RectangleEdge.BOTTOM)) { result = RectangleEdge.BOTTOM; } else if (this.equals(RectangleEdge.LEFT)) { result = RectangleEdge.LEFT; } else if (this.equals(RectangleEdge.RIGHT)) { result = RectangleEdge.RIGHT; } return result; }
/** * 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 selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { if (RectangleEdge.isTopOrBottom(edge)) { selectHorizontalAutoTickUnit(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { selectVerticalAutoTickUnit(g2, dataArea, edge); } }
/** * Returns the maximum of the relevant dimension (height or width) of the * subcategory labels. * * @param g2 the graphics device. * @param edge the edge. * * @return The maximum dimension. */ private double getMaxDim(Graphics2D g2, RectangleEdge edge) { double result = 0.0; g2.setFont(this.subLabelFont); FontMetrics fm = g2.getFontMetrics(); Iterator iterator = this.subCategories.iterator(); while (iterator.hasNext()) { Comparable subcategory = (Comparable) iterator.next(); String label = subcategory.toString(); Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm); double dim = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { dim = bounds.getWidth(); } else { // must be top or bottom dim = bounds.getHeight(); } result = Math.max(result, dim); } return result; }
/** * Returns the edge for a domain axis. * * @param index the axis index. * * @return The edge (never <code>null</code>). */ public RectangleEdge getDomainAxisEdge(int index) { RectangleEdge result = null; AxisLocation location = getDomainAxisLocation(index); if (location != null) { result = Plot.resolveDomainAxisLocation(location, this.orientation); } else { result = RectangleEdge.opposite(getDomainAxisEdge(0)); } return result; }
double cursor = RectangleEdge.coordinate(dataArea, edge); AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info); if (parentState == null) {
/** * Fetches the latest legend items. */ protected void fetchLegendItems() { this.items.clear(); RectangleEdge p = getPosition(); if (RectangleEdge.isTopOrBottom(p)) { this.items.setArrangement(this.hLayout); } else { this.items.setArrangement(this.vLayout); } for (int s = 0; s < this.sources.length; s++) { LegendItemCollection legendItems = this.sources[s].getLegendItems(); if (legendItems != null) { for (int i = 0; i < legendItems.getItemCount(); i++) { LegendItem item = legendItems.get(i); Block block = createLegendItemBlock(item); this.items.add(block); } } } }
/** * Ensures that serialization returns the unique instances. * * @return The object. * * @throws ObjectStreamException if there is a problem. */ private Object readResolve() throws ObjectStreamException { RectangleEdge result = null; if (this.equals(RectangleEdge.TOP)) { result = RectangleEdge.TOP; } else if (this.equals(RectangleEdge.BOTTOM)) { result = RectangleEdge.BOTTOM; } else if (this.equals(RectangleEdge.LEFT)) { result = RectangleEdge.LEFT; } else if (this.equals(RectangleEdge.RIGHT)) { result = RectangleEdge.RIGHT; } return result; }
/** * A regular translation from a data value to a Java2D value. * * @param value the value. * @param area the data area. * @param edge the edge along which the axis lies. * * @return The Java2D coordinate. */ private double trans(double value, Rectangle2D area, RectangleEdge edge) { double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getX() + area.getWidth(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getMaxY() - area.getHeight(); } if (isInverted()) { return max - ((value - this.displayStart) / (this.displayEnd - this.displayStart)) * (max - min); } else { return min + ((value - this.displayStart) / (this.displayEnd - this.displayStart)) * (max - min); } }
/** * Converts a length in data coordinates into the corresponding length in * Java2D coordinates. * * @param length the length. * @param area the plot area. * @param edge the edge along which the axis lies. * * @return The length in Java2D coordinates. */ public double lengthToJava2D(double length, Rectangle2D area, RectangleEdge edge) { double axisLength = 0.0; if (this.displayEnd > this.displayStart) { axisLength = this.displayEnd - this.displayStart; } else { axisLength = (this.fixedRange.getUpperBound() - this.displayStart) + (this.displayEnd - this.fixedRange.getLowerBound()); } double areaLength = 0.0; if (RectangleEdge.isLeftOrRight(edge)) { areaLength = area.getHeight(); } else { areaLength = area.getWidth(); } return (length / axisLength) * areaLength; }