List of usage examples for org.jfree.ui RectangleEdge isTopOrBottom
public static boolean isTopOrBottom(final RectangleEdge edge)
true if the edge is TOP or BOTTOM, and false otherwise. From source file:net.sourceforge.processdash.ui.lib.chart.PaddedAxisHelper.java
public Rectangle2D removePadding(Rectangle2D area, RectangleEdge edge) { boolean inverted = axis.isInverted(); if (RectangleEdge.isTopOrBottom(edge)) { double xPad = inverted ? upperPad : lowerPad; double width = area.getWidth() - upperPad - lowerPad; return new Rectangle2D.Double(area.getX() + xPad, area.getY(), width, area.getHeight()); } else {// ww w. ja v a2 s . c o m double yPad = inverted ? lowerPad : upperPad; double height = area.getHeight() - upperPad - lowerPad; return new Rectangle2D.Double(area.getX(), area.getY() + yPad, area.getWidth(), height); } }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double valueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange();//from w w w . ja v a 2 s.co m double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getMinX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } value = log(value); if (isInverted()) return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); else return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); }
From source file:peakml.util.jfreechart.LognAxis.java
@Override public double java2DToValue(double java2DValue, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange();/* w ww . j a va 2s.c om*/ double axisMin = log(range.getLowerBound()); double axisMax = log(range.getUpperBound()); double min = 0.0, max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } if (isInverted()) return pow(axisMax - ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); else return pow(axisMin + ((java2DValue - min) / (max - min)) * (axisMax - axisMin)); }
From source file:com.newatlanta.bluedragon.CategoryAxis.java
public AxisSpace reserveSpace(Graphics2D g2, Plot plot, Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) {/*from ww w . j a v a 2 s .c o m*/ // create a new space object if one wasn't supplied... if (space == null) { space = new AxisSpace(); } // if the axis is not visible, no additional space is required... if (!isVisible()) { return space; } // calculate the max size of the tick labels (if visible)... double tickLabelHeight = 0.0; double tickLabelWidth = 0.0; if (isTickLabelsVisible()) { g2.setFont(getTickLabelFont()); AxisState state = new AxisState(); // we call refresh ticks just to get the maximum width or height if (RectangleEdge.isTopOrBottom(edge)) { // BEGIN fix for category labels that wrap // If space has been reserved to the left and right then we need to // reduce the plot area // by this amount so that the space needed by category labels that wrap // on to multiple lines // will be calculated properly. Rectangle2D newPlotArea = new Rectangle2D.Double(plotArea.getX(), plotArea.getY(), plotArea.getWidth() - space.getLeft() - space.getRight(), plotArea.getHeight()); refreshTicks(g2, state, newPlotArea, edge); // END fix for category labels that wrap } else { refreshTicks(g2, state, plotArea, edge); } if (edge == RectangleEdge.TOP) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.BOTTOM) { tickLabelHeight = state.getMax(); } else if (edge == RectangleEdge.LEFT) { tickLabelWidth = state.getMax(); } else if (edge == RectangleEdge.RIGHT) { tickLabelWidth = state.getMax(); } } // get the axis label size and update the space object... Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); double labelHeight = 0.0; double labelWidth = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { labelHeight = labelEnclosure.getHeight(); space.add(labelHeight + tickLabelHeight + this.getCategoryLabelPositionOffset(), edge); } else if (RectangleEdge.isLeftOrRight(edge)) { labelWidth = labelEnclosure.getWidth(); space.add(labelWidth + tickLabelWidth + this.getCategoryLabelPositionOffset(), edge); } return space; }
From source file:figs.treeVisualization.gui.PhyloDateAxis.java
/** * Translates the data value to the display coordinates (Java 2D User Space) * of the chart./* w w w . ja va 2 s.c om*/ * * @param value the date to be plotted. * @param area the rectangle (in Java2D space) where the data is to be * plotted. * @param edge the axis location. * * @return The coordinate corresponding to the supplied data value. * * Original method is in <code>org.jfree.chart.axis.DateAxis</code> */ @Override public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Timeline timeline = this.getTimeline(); value = timeline.toTimelineValue((long) value); DateRange range = (DateRange) getRange(); double axisMin = timeline.toTimelineValue(range.getLowerDate()); double axisMax = timeline.toTimelineValue(range.getUpperDate()); double result = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { double minX = area.getX(); double maxX = area.getMaxX(); if (isInverted()) { result = maxX + ((value - axisMin) / (axisMax - axisMin)) * (minX - maxX); } else { result = minX + ((value - axisMin) / (axisMax - axisMin)) * (maxX - minX); } } else if (RectangleEdge.isLeftOrRight(edge)) { //double minY = area.getMinY(); //double maxY = area.getMaxY(); double minY = area.getY(); double maxY = area.getHeight(); if (isInverted()) { result = minY + (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } else { result = maxY - (((value - axisMin) / (axisMax - axisMin)) * (maxY - minY)); } } return result; }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Converts a Java2D coordinate to an axis value, assuming that the * axis covers the specified <code>edge</code> of the <code>area</code>. * /*from ww w. j av a 2 s. c o m*/ * @param java2DValue the Java2D coordinate. * @param area the area. * @param edge the edge that the axis belongs to. * * @return A value along the axis scale. */ public double java2DToValue(double java2DValue, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = area.getMaxY(); max = area.getY(); } double log = 0.0; if (isInverted()) { log = axisMax - (java2DValue - min) / (max - min) * (axisMax - axisMin); } else { log = axisMin + (java2DValue - min) / (max - min) * (axisMax - axisMin); } return calculateValue(log); }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * Converts a value on the axis scale to a Java2D coordinate relative to * the given <code>area</code>, based on the axis running along the * specified <code>edge</code>. * //from ww w .ja va2 s . com * @param value the data value. * @param area the area. * @param edge the edge. * * @return The Java2D coordinate corresponding to <code>value</code>. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { Range range = getRange(); double axisMin = calculateLog(range.getLowerBound()); double axisMax = calculateLog(range.getUpperBound()); value = calculateLog(value); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = area.getX(); max = area.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { max = area.getMinY(); min = area.getMaxY(); } if (isInverted()) { return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); } else { return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); } }
From source file:org.jfree.experimental.chart.axis.LogAxis.java
/** * 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.//from w ww . j av a2 s .c o m * @param state the axis state. * @param dataArea the area in which the plot should be drawn. * @param edge the location of the axis. * * @return A list of ticks. * */ public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { List result = new java.util.ArrayList(); if (RectangleEdge.isTopOrBottom(edge)) { result = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { result = refreshTicksVertical(g2, dataArea, edge); } return result; }
From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java
protected void initChart(JFreeChart chart, ChartModel chartModel) { if (chartModel.getBackground() instanceof Integer) { chart.setBackgroundPaint(new Color(0x00FFFFFF & (Integer) chartModel.getBackground())); } else {/*from w w w. j a v a2 s . co m*/ chart.setBackgroundPaint(Color.WHITE); } if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null) && (chartModel.getTitle().getText().trim().length() > 0)) { Font font = ChartUtils.getFont(chartModel.getTitle().getFontFamily(), chartModel.getTitle().getFontStyle(), chartModel.getTitle().getFontWeight(), chartModel.getTitle().getFontSize()); if (font != null) { chart.getTitle().setFont(font); } RectangleEdge rectangleEdge = RectangleEdge.TOP; if (chartModel.getTitle().getLocation() != null) { switch (chartModel.getTitle().getLocation()) { case RIGHT: rectangleEdge = RectangleEdge.BOTTOM; break; case LEFT: rectangleEdge = RectangleEdge.LEFT; break; case BOTTOM: rectangleEdge = RectangleEdge.BOTTOM; break; } } chart.getTitle().setPosition(rectangleEdge); if (RectangleEdge.isTopOrBottom(rectangleEdge)) { HorizontalAlignment horizontalAlignment = HorizontalAlignment.CENTER; if (chartModel.getTitle().getAlignment() != null) { switch (chartModel.getTitle().getAlignment()) { case LEFT: horizontalAlignment = horizontalAlignment.LEFT; break; case RIGHT: horizontalAlignment = horizontalAlignment.RIGHT; break; } } chart.getTitle().setHorizontalAlignment(horizontalAlignment); } } if ((chartModel.getLegend() != null) && chartModel.getLegend().getVisible()) { Font font = ChartUtils.getFont(chartModel.getLegend().getFontFamily(), chartModel.getLegend().getFontStyle(), chartModel.getLegend().getFontWeight(), chartModel.getLegend().getFontSize()); if (font != null) { chart.getLegend().setItemFont(font); } if (!chartModel.getLegend().getBorderVisible()) { chart.getLegend().setFrame(BlockBorder.NONE); } } chart.setBorderVisible(chartModel.getBorderVisible()); if (chartModel.getBorderColor() instanceof Integer) { chart.setBorderPaint(new Color(0x00FFFFFF & (Integer) chartModel.getBorderColor())); } for (StyledText subtitle : chartModel.getSubtitles()) { if ((subtitle.getText()) != null && (subtitle.getText().trim().length() > 0)) { TextTitle textTitle = new TextTitle(subtitle.getText()); Font font = ChartUtils.getFont(subtitle.getFontFamily(), subtitle.getFontStyle(), subtitle.getFontWeight(), subtitle.getFontSize()); if (font != null) { textTitle.setFont(font); } if (subtitle.getColor() != null) { textTitle.setPaint(new Color(0x00FFFFFF & subtitle.getColor())); } if (subtitle.getBackgroundColor() != null) { textTitle.setBackgroundPaint(new Color(0x00FFFFFF & subtitle.getBackgroundColor())); } chart.addSubtitle(textTitle); } } }
From source file:org.gumtree.vis.plot1d.LogarithmizableAxis.java
/** * Converts a data value to a coordinate in Java2D space, assuming that * the axis runs along one edge of the specified plotArea. * Note that it is possible for the coordinate to fall outside the * plotArea.// w ww . j a v a2s . c o m * * @param value the data value. * @param plotArea the area for plotting the data. * @param edge the axis location. * * @return The Java2D coordinate. */ public double logValueToJava2D(double value, Rectangle2D plotArea, RectangleEdge edge) { Range range = getRange(); double axisMin = switchedLog10(range.getLowerBound()); double axisMax = switchedLog10(range.getUpperBound()); double min = 0.0; double max = 0.0; if (RectangleEdge.isTopOrBottom(edge)) { min = plotArea.getMinX(); max = plotArea.getMaxX(); } else if (RectangleEdge.isLeftOrRight(edge)) { min = plotArea.getMaxY(); max = plotArea.getMinY(); } value = switchedLog10(value); if (isInverted()) { return max - (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } else { return min + (((value - axisMin) / (axisMax - axisMin)) * (max - min)); } }