org.jfree.chart.util.RectangleEdge Java Examples
The following examples show how to use
org.jfree.chart.util.RectangleEdge.
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: jMutRepair_0046_s.java From coming with MIT License | 6 votes |
/** * Returns a rectangle that encloses the axis label. This is typically * used for layout purposes (it gives the maximum dimensions of the label). * * @param g2 the graphics device. * @param edge the edge of the plot area along which the axis is measuring. * * @return The enclosing rectangle. */ protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) { Rectangle2D result = new Rectangle2D.Double(); String axisLabel = getLabel(); if (axisLabel != null && !axisLabel.equals("")) { FontMetrics fm = g2.getFontMetrics(getLabelFont()); Rectangle2D bounds = TextUtilities.getTextBounds(axisLabel, g2, fm); RectangleInsets insets = getLabelInsets(); bounds = insets.createOutsetRectangle(bounds); double angle = getLabelAngle(); if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { angle = angle - Math.PI / 2.0; } double x = bounds.getCenterX(); double y = bounds.getCenterY(); AffineTransform transformer = AffineTransform.getRotateInstance(angle, x, y); Shape labelBounds = transformer.createTransformedShape(bounds); result = labelBounds.getBounds2D(); } return result; }
Example #2
Source File: Cardumen_00143_t.java From coming with MIT License | 6 votes |
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the range axis... double java2D = 0.0; if (this.orientation == PlotOrientation.HORIZONTAL) { java2D = x; } else if (this.orientation == PlotOrientation.VERTICAL) { java2D = y; } RectangleEdge edge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), this.orientation); double value = getRangeAxis().java2DToValue( java2D, info.getDataArea(), edge); setAnchorValue(value); setRangeCrosshairValue(value); } }
Example #3
Source File: CyclicNumberAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Selects a tick unit when the axis is displayed horizontally. * * @param g2 the graphics device. * @param drawArea the drawing area. * @param dataArea the data area. * @param edge the side of the rectangle on which the axis is displayed. */ protected void selectHorizontalAutoTickUnit(Graphics2D g2, Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) { double tickLabelWidth = estimateMaximumTickLabelWidth(g2, getTickUnit()); // Compute number of labels double n = getRange().getLength() * tickLabelWidth / dataArea.getWidth(); setTickUnit( (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n), false, false ); }
Example #4
Source File: JGenProg2017_005_s.java From coming with MIT License | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #5
Source File: 1_XYPlot.java From SimFix with GNU General Public License v2.0 | 6 votes |
/** * Utility method for drawing a horizontal line across the data area of the * plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param value the coordinate, where to draw the line. * @param stroke the stroke to use. * @param paint the paint to use. */ protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { ValueAxis axis = getRangeAxis(); if (getOrientation() == PlotOrientation.HORIZONTAL) { axis = getDomainAxis(); } if (axis.getRange().contains(value)) { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } }
Example #6
Source File: Arja_00131_s.java From coming with MIT License | 6 votes |
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); this.pieChart.setTitle(seriesTitle); this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
Example #7
Source File: Arja_00149_s.java From coming with MIT License | 6 votes |
/** * Adds a block to the arrangement manager at the specified edge. * * @param block the block (<code>null</code> permitted). * @param key the edge (an instance of {@link RectangleEdge}) or * <code>null</code> for the center block. */ public void add(Block block, Object key) { if (key == null) { this.centerBlock = block; } else { RectangleEdge edge = (RectangleEdge) key; if (edge == RectangleEdge.TOP) { this.topBlock = block; } else if (edge == RectangleEdge.BOTTOM) { this.bottomBlock = block; } else if (edge == RectangleEdge.LEFT) { this.leftBlock = block; } else if (edge == RectangleEdge.RIGHT) { this.rightBlock = block; } } }
Example #8
Source File: Chart_26_Axis_s.java From coming with MIT License | 6 votes |
/** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); }
Example #9
Source File: jMutRepair_0046_s.java From coming with MIT License | 6 votes |
/** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); }
Example #10
Source File: jKali_001_t.java From coming with MIT License | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #11
Source File: Chart_19_CategoryPlot_t.java From coming with MIT License | 6 votes |
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the range axis... double java2D = 0.0; if (this.orientation == PlotOrientation.HORIZONTAL) { java2D = x; } else if (this.orientation == PlotOrientation.VERTICAL) { java2D = y; } RectangleEdge edge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), this.orientation); double value = getRangeAxis().java2DToValue( java2D, info.getDataArea(), edge); setAnchorValue(value); setRangeCrosshairValue(value); } }
Example #12
Source File: 1_CategoryPlot.java From SimFix with GNU General Public License v2.0 | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #13
Source File: CategoryAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Returns the middle coordinate (in Java2D space) for a series within a * category. * * @param category the category (<code>null</code> not permitted). * @param seriesKey the series key (<code>null</code> not permitted). * @param dataset the dataset (<code>null</code> not permitted). * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); * @param area the area (<code>null</code> not permitted). * @param edge the edge (<code>null</code> not permitted). * * @return The coordinate in Java2D space. * * @since 1.0.7 */ public double getCategorySeriesMiddle(Comparable category, Comparable seriesKey, CategoryDataset dataset, double itemMargin, Rectangle2D area, RectangleEdge edge) { int categoryIndex = dataset.getColumnIndex(category); int categoryCount = dataset.getColumnCount(); int seriesIndex = dataset.getRowIndex(seriesKey); int seriesCount = dataset.getRowCount(); double start = getCategoryStart(categoryIndex, categoryCount, area, edge); double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); double width = end - start; if (seriesCount == 1) { return start + width / 2.0; } else { double gap = (width * itemMargin) / (seriesCount - 1); double ww = (width * (1 - itemMargin)) / seriesCount; return start + (seriesIndex * (ww + gap)) + ww / 2.0; } }
Example #14
Source File: Arja_001_t.java From coming with MIT License | 6 votes |
/** * Creates a new plot. * * @param dataset the dataset (<code>null</code> permitted). */ public MultiplePiePlot(CategoryDataset dataset) { super(); this.dataset = dataset; PiePlot piePlot = new PiePlot(null); this.pieChart = new JFreeChart(piePlot); this.pieChart.removeLegend(); this.dataExtractOrder = TableOrder.BY_COLUMN; this.pieChart.setBackgroundPaint(null); TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); seriesTitle.setPosition(RectangleEdge.BOTTOM); if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } this.aggregatedItemsKey = "Other"; this.aggregatedItemsPaint = Color.lightGray; this.sectionPaints = new HashMap(); }
Example #15
Source File: Cardumen_0082_s.java From coming with MIT License | 6 votes |
/** * Utility method for drawing a horizontal line across the data area of the * plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param value the coordinate, where to draw the line. * @param stroke the stroke to use. * @param paint the paint to use. */ protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { ValueAxis axis = getRangeAxis(); if (getOrientation() == PlotOrientation.HORIZONTAL) { axis = getDomainAxis(); } if (axis.getRange().contains(value)) { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } }
Example #16
Source File: SymbolAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the axis on a Java 2D graphics device (such as the screen or a * printer). * * @param g2 the graphics device (<code>null</code> not permitted). * @param cursor the cursor location. * @param plotArea the area within which the plot and axes should be drawn * (<code>null</code> not permitted). * @param dataArea the area within which the data should be drawn * (<code>null</code> not permitted). * @param edge the axis location (<code>null</code> not permitted). * @param plotState collects information about the plot * (<code>null</code> permitted). * * @return The axis state (never <code>null</code>). */ public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { AxisState info = new AxisState(cursor); if (isVisible()) { info = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); } if (this.gridBandsVisible) { drawGridBands(g2, plotArea, dataArea, edge, info.getTicks()); } return info; }
Example #17
Source File: ValueAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Calculates the anchor point for a tick label. * * @param tick the tick. * @param cursor the cursor. * @param dataArea the data area. * @param edge the edge on which the axis is drawn. * * @return The x and y coordinates of the anchor point. */ protected float[] calculateAnchorPoint(ValueTick tick, double cursor, Rectangle2D dataArea, RectangleEdge edge) { RectangleInsets insets = getTickLabelInsets(); float[] result = new float[2]; if (edge == RectangleEdge.TOP) { result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); result[1] = (float) (cursor - insets.getBottom() - 2.0); } else if (edge == RectangleEdge.BOTTOM) { result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); result[1] = (float) (cursor + insets.getTop() + 2.0); } else if (edge == RectangleEdge.LEFT) { result[0] = (float) (cursor - insets.getLeft() - 2.0); result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); } else if (edge == RectangleEdge.RIGHT) { result[0] = (float) (cursor + insets.getRight() + 2.0); result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); } return result; }
Example #18
Source File: Cardumen_009_s.java From coming with MIT License | 6 votes |
/** * Utility method for drawing a vertical line on the data area of the plot. * * @param g2 the graphics device. * @param dataArea the data area. * @param value the coordinate, where to draw the line. * @param stroke the stroke to use. * @param paint the paint to use. */ protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, double value, Stroke stroke, Paint paint) { ValueAxis axis = getDomainAxis(); if (getOrientation() == PlotOrientation.HORIZONTAL) { axis = getRangeAxis(); } if (axis.getRange().contains(value)) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); } }
Example #19
Source File: jMutRepair_001_t.java From coming with MIT License | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #20
Source File: JGenProg2017_0082_t.java From coming with MIT License | 6 votes |
/** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); }
Example #21
Source File: ModuloAxis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Translates a data value to a Java2D coordinate. * * @param value the value. * @param area the area. * @param edge the edge. * * @return A Java2D coordinate. */ public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { double result = 0.0; double v = mapValueToFixedRange(value); if (this.displayStart < this.displayEnd) { // regular number axis result = trans(v, area, edge); } else { // displayStart > displayEnd, need to handle split double cutoff = (this.displayStart + this.displayEnd) / 2.0; double length1 = this.fixedRange.getUpperBound() - this.displayStart; double length2 = this.displayEnd - this.fixedRange.getLowerBound(); if (v > cutoff) { result = transStart(v, area, edge, length1, length2); } else { result = transEnd(v, area, edge, length1, length2); } } return result; }
Example #22
Source File: DateAxis.java From astor with GNU General Public License v2.0 | 6 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 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 = null; if (RectangleEdge.isTopOrBottom(edge)) { result = refreshTicksHorizontal(g2, dataArea, edge); } else if (RectangleEdge.isLeftOrRight(edge)) { result = refreshTicksVertical(g2, dataArea, edge); } return result; }
Example #23
Source File: LegendTitle.java From astor with GNU General Public License v2.0 | 6 votes |
/** * 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); } } } }
Example #24
Source File: patch1-Chart-13-Nopol2017_patch1-Chart-13-Nopol2017_s.java From coming with MIT License | 6 votes |
/** * Adds a block to the arrangement manager at the specified edge. * * @param block the block (<code>null</code> permitted). * @param key the edge (an instance of {@link RectangleEdge}) or * <code>null</code> for the center block. */ public void add(Block block, Object key) { if (key == null) { this.centerBlock = block; } else { RectangleEdge edge = (RectangleEdge) key; if (edge == RectangleEdge.TOP) { this.topBlock = block; } else if (edge == RectangleEdge.BOTTOM) { this.bottomBlock = block; } else if (edge == RectangleEdge.LEFT) { this.leftBlock = block; } else if (edge == RectangleEdge.RIGHT) { this.rightBlock = block; } } }
Example #25
Source File: CategoryPlot.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws a range crosshair. * * @param g2 the graphics target. * @param dataArea the data area. * @param orientation the plot orientation. * @param value the crosshair value. * @param axis the axis against which the value is measured. * @param stroke the stroke used to draw the crosshair line. * @param paint the paint used to draw the crosshair line. * * @since 1.0.5 */ protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, PlotOrientation orientation, double value, ValueAxis axis, Stroke stroke, Paint paint) { if (!axis.getRange().contains(value)) { return; } Line2D line = null; if (orientation == PlotOrientation.HORIZONTAL) { double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM); line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY()); } else { double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy); } g2.setStroke(stroke); g2.setPaint(paint); g2.draw(line); }
Example #26
Source File: BorderArrangement.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Adds a block to the arrangement manager at the specified edge. * * @param block the block (<code>null</code> permitted). * @param key the edge (an instance of {@link RectangleEdge}) or * <code>null</code> for the center block. */ public void add(Block block, Object key) { if (key == null) { this.centerBlock = block; } else { RectangleEdge edge = (RectangleEdge) key; if (edge == RectangleEdge.TOP) { this.topBlock = block; } else if (edge == RectangleEdge.BOTTOM) { this.bottomBlock = block; } else if (edge == RectangleEdge.LEFT) { this.leftBlock = block; } else if (edge == RectangleEdge.RIGHT) { this.rightBlock = block; } } }
Example #27
Source File: patch1-Chart-26-jMutRepair_patch1-Chart-26-jMutRepair_t.java From coming with MIT License | 6 votes |
/** * Handles a 'click' on the plot by updating the anchor value. * * @param x x-coordinate of the click (in Java2D space). * @param y y-coordinate of the click (in Java2D space). * @param info information about the plot's dimensions. * */ public void handleClick(int x, int y, PlotRenderingInfo info) { Rectangle2D dataArea = info.getDataArea(); if (dataArea.contains(x, y)) { // set the anchor value for the range axis... double java2D = 0.0; if (this.orientation == PlotOrientation.HORIZONTAL) { java2D = x; } else if (this.orientation == PlotOrientation.VERTICAL) { java2D = y; } RectangleEdge edge = Plot.resolveRangeAxisLocation( getRangeAxisLocation(), this.orientation); double value = getRangeAxis().java2DToValue( java2D, info.getDataArea(), edge); setAnchorValue(value); setRangeCrosshairValue(value); } }
Example #28
Source File: Axis.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); }
Example #29
Source File: JGenProg2017_0082_s.java From coming with MIT License | 6 votes |
/** * Draws an axis line at the current cursor position and edge. * * @param g2 the graphics device. * @param cursor the cursor position. * @param dataArea the data area. * @param edge the edge. */ protected void drawAxisLine(Graphics2D g2, double cursor, Rectangle2D dataArea, RectangleEdge edge) { Line2D axisLine = null; if (edge == RectangleEdge.TOP) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.BOTTOM) { axisLine = new Line2D.Double(dataArea.getX(), cursor, dataArea.getMaxX(), cursor); } else if (edge == RectangleEdge.LEFT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } else if (edge == RectangleEdge.RIGHT) { axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, dataArea.getMaxY()); } g2.setPaint(this.axisLinePaint); g2.setStroke(this.axisLineStroke); g2.draw(axisLine); }
Example #30
Source File: Arja_00132_t.java From coming with MIT License | 6 votes |
/** * Adds a block to the arrangement manager at the specified edge. * * @param block the block (<code>null</code> permitted). * @param key the edge (an instance of {@link RectangleEdge}) or * <code>null</code> for the center block. */ public void add(Block block, Object key) { if (key == null) { this.centerBlock = block; } else { RectangleEdge edge = (RectangleEdge) key; if (edge == RectangleEdge.TOP) { this.topBlock = block; } else if (edge == RectangleEdge.BOTTOM) { this.bottomBlock = block; } else if (edge == RectangleEdge.LEFT) { this.leftBlock = block; } else if (edge == RectangleEdge.RIGHT) { this.rightBlock = block; } } }