List of usage examples for java.awt.geom Rectangle2D getMinX
public double getMinX()
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeMaskYMax(double y) { Rectangle2D frame = getSelectedMask().getRectangleFrame(); getSelectedMask().setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), Math.min(frame.getMinY(), y), frame.getWidth(), Math.abs(frame.getMinY() - y))); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeMaskYMin(double y) { Rectangle2D frame = getSelectedMask().getRectangleFrame(); getSelectedMask().setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), Math.min(frame.getMaxY(), y), frame.getWidth(), Math.abs(frame.getMaxY() - y))); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void changeMaskXMax(double x) { Rectangle2D frame = getSelectedMask().getRectangleFrame(); getSelectedMask().setRectangleFrame(new Rectangle2D.Double(Math.min(frame.getMinX(), x), frame.getMinY(), Math.abs(frame.getMinX() - x), frame.getHeight())); }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
private double userX(MouseEvent event) { Rectangle2D rectangle = getScaledDataArea(); double minX = rectangle.getMinX(); double maxX = rectangle.getMaxX(); Plot plot = chart.getPlot();/*from w w w .j a va 2 s . co m*/ int xc = event.getX(); ValueAxis xa = this.getHorizontalValueAxis(plot); double xmin = xa.getLowerBound(); double xmax = xa.getUpperBound(); double u = (xc - minX) / (maxX - minX); return (u * (xmax - xmin) + xmin); }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
private void moveMask(Point2D point) { if (maskMovePoint != null && getSelectedMask() != null) { Rectangle2D frame = getSelectedMask().getRectangleFrame(); getSelectedMask().setRectangleFrame(new Rectangle2D.Double( frame.getMinX() + point.getX() - maskMovePoint.getX(), frame.getMinY() + point.getY() - maskMovePoint.getY(), frame.getWidth(), frame.getHeight())); maskMovePoint = point;/* w w w . ja v a 2s . co m*/ fireMaskUpdateEvent(getSelectedMask()); } }
From source file:org.tsho.dmc2.core.chart.AbstractDmcPlot.java
/** * Draws the fast scatter plot on a Java 2D graphics device (such as the screen or * a printer)./*from w w w.ja v a2s . c o m*/ * * @param g2 the graphics device. * @param plotArea the area within which the plot (including axis labels) should be drawn. * @param info collects chart drawing information (<code>null</code> permitted). */ public void draw(Graphics2D g2, Rectangle2D plotArea, PlotState parentState, PlotRenderingInfo info) { // if (data == null) // return; // set up info collection... if (info != null) { info.setPlotArea(plotArea); } // adjust the drawing area for plot insets (if any)... Insets insets = getInsets(); if (insets != null) { plotArea.setRect(plotArea.getX() + insets.left, plotArea.getY() + insets.top, plotArea.getWidth() - insets.left - insets.right, plotArea.getHeight() - insets.top - insets.bottom); } AxisSpace space = new AxisSpace(); space = this.domainAxis.reserveSpace(g2, this, plotArea, RectangleEdge.BOTTOM, space); space = this.rangeAxis.reserveSpace(g2, this, plotArea, RectangleEdge.LEFT, space); Rectangle2D dataArea = space.shrink(plotArea, null); if (info != null) { info.setDataArea(dataArea); } // draw the plot background and axes... drawBackground(g2, dataArea); /* if automatic bounds... */ if (!isNoData()) { if (this instanceof DmcRenderablePlot) { DmcPlotRenderer renderer; renderer = ((DmcRenderablePlot) this).getPlotRenderer(); if (renderer != null) { renderer.initialize(); if (renderer.getState() == DmcPlotRenderer.STATE_STOPPED) { return; } } } } AxisState domainAxisState = null, rangeAxisState = null; if (this.domainAxis != null) { double cursor; cursor = dataArea.getMaxY(); domainAxisState = this.domainAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.BOTTOM, info); // cursor = info.getCursor(); } if (this.rangeAxis != null) { double cursor; cursor = dataArea.getMinX(); rangeAxisState = this.rangeAxis.draw(g2, cursor, plotArea, dataArea, RectangleEdge.LEFT, info); } if (drawGridlines == true && domainAxisState != null && rangeAxisState != null) { drawGridlines(g2, dataArea, domainAxisState.getTicks(), rangeAxisState.getTicks()); } Shape originalClip = g2.getClip(); g2.clip(dataArea); // Composite originalComposite = g2.getComposite(); // g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, // getForegroundAlpha())); // g2.setStroke(new BasicStroke(12.0F)); if (isNoData()) { drawNoDataMessage(g2, plotArea); } else { drawPlot(g2, dataArea, info); } g2.setClip(originalClip); drawOutline(g2, dataArea); }
From source file:org.tsho.dmc2.core.chart.jfree.DmcChartPanel.java
/** * Draws a vertical line used to trace the mouse position to the horizontal axis. * * @param x the x-coordinate of the trace line. *///from w w w . ja v a 2s.c om private void drawHorizontalAxisTrace(int x) { Graphics2D g2 = (Graphics2D) getGraphics(); Rectangle2D dataArea = getScaledDataArea(); g2.setXORMode(java.awt.Color.orange); if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { if (verticalTraceLine != null) { g2.draw(verticalTraceLine); verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } else { verticalTraceLine = new Line2D.Float(x, (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); } g2.draw(verticalTraceLine); } else { if (horizontalTraceLine != null) { g2.draw(horizontalTraceLine); horizontalTraceLine = null; } if (verticalTraceLine != null) { g2.draw(verticalTraceLine); verticalTraceLine = null; } } }
From source file:org.gumtree.vis.hist2d.Hist2DPanel.java
@Override public void moveSelectedMask(int direction) { Abstract2DMask selectedMask = getSelectedMask(); if (selectedMask == null) { return;/*w w w .j a v a2 s .c o m*/ } double blockWidth = 0; double blockHeight = 0; try { XYBlockRenderer render = (XYBlockRenderer) ((XYPlot) getChart().getPlot()).getRenderer(); blockWidth = render.getBlockWidth(); blockHeight = render.getBlockHeight(); if (getChart().getXYPlot().getDomainAxis().isInverted()) { blockWidth = -blockHeight; } if (getChart().getXYPlot().getRangeAxis().isInverted()) { blockHeight = -blockHeight; } } catch (Exception e) { e.printStackTrace(); return; } Rectangle2D frame = selectedMask.getRectangleFrame(); switch (direction) { case SWT.ARROW_UP: selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), frame.getMinY() + blockHeight, frame.getWidth(), frame.getHeight())); break; case SWT.ARROW_LEFT: selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX() - blockWidth, frame.getMinY(), frame.getWidth(), frame.getHeight())); break; case SWT.ARROW_RIGHT: selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX() + blockWidth, frame.getMinY(), frame.getWidth(), frame.getHeight())); break; case SWT.ARROW_DOWN: selectedMask.setRectangleFrame(new Rectangle2D.Double(frame.getMinX(), frame.getMinY() - blockHeight, frame.getWidth(), frame.getHeight())); break; default: break; } repaint(); fireMaskUpdateEvent(getSelectedMask()); }
From source file:org.gumtree.vis.plot1d.Plot1DPanel.java
@Override protected void drawToolTipFollower(Graphics2D g2, int x, int y) { Rectangle2D dataArea = getScreenDataArea(); if (((int) dataArea.getMinX() <= x) && (x <= (int) dataArea.getMaxX()) && ((int) dataArea.getMinY() <= y) && (y <= (int) dataArea.getMaxY())) { String text = ""; if (indexInTooltip) { text += "#" + getItemIndex() + ", "; }/* w ww . j a va 2 s . c o m*/ text += String.format("(%." + mouseFollowerXPrecision + "f, %." + mouseFollowerYPrecision + "f", getChartX(), getChartY()); boolean isErrorEnabled = false; XYItemRenderer renderer = getXYPlot().getRenderer(); if (renderer instanceof XYErrorRenderer) { isErrorEnabled = ((XYErrorRenderer) renderer).getDrawYError(); } if (isErrorEnabled) { text += String.format(" \u00B1%." + mouseFollowerYPrecision + "f", getChartError()); } text += ")"; int xLoc = x + 10; int yLoc = y + 20; double width = text.length() * 5.5; double height = 15; if (xLoc + width > dataArea.getMaxX()) { xLoc = (int) (x - width); } if (yLoc + height > dataArea.getMaxY()) { yLoc = (int) (y - height); } Rectangle2D toolTipArea = new Rectangle2D.Double(xLoc, yLoc, width, height); g2.setColor(Color.lightGray); g2.fill(toolTipArea); g2.setColor(Color.black); g2.drawString(text, xLoc + 3, yLoc + 11); } }
From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java
public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { // check the value we are plotting... Number dataValue = dataset.getValue(row, column); if (dataValue == null) { return;/*from w ww . j a v a 2 s . c o m*/ } double value = dataValue.doubleValue(); Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), dataArea.getY() + getYOffset(), dataArea.getWidth() - getXOffset(), dataArea.getHeight() - getYOffset()); PlotOrientation orientation = plot.getOrientation(); double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, state, row, column); double[] barL0L1 = calculateBarL0L1(value); if (barL0L1 == null) { return; // the bar is not visible } RectangleEdge edge = plot.getRangeAxisEdge(); double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); double barL0 = Math.min(transL0, transL1); double barLength = Math.abs(transL1 - transL0); // draw the bar... Rectangle2D bar = null; if (orientation == PlotOrientation.HORIZONTAL) { bar = new Rectangle2D.Double(barL0, barW0, barLength, state.getBarWidth()); } else { bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), barLength); } Paint itemPaint = getItemPaint(row, column); if (itemPaint instanceof GradientPaint) { itemPaint = getGradientPaintTransformer().transform((GradientPaint) itemPaint, bar); } g2.setPaint(itemPaint); g2.fill(bar); double x0 = bar.getMinX(); double x1 = x0 + getXOffset(); double x2 = bar.getMaxX(); double x3 = x2 + getXOffset(); double y0 = bar.getMinY() - getYOffset(); double y1 = bar.getMinY(); double y2 = bar.getMaxY() - getYOffset(); double y3 = bar.getMaxY(); GeneralPath bar3dRight = null; GeneralPath bar3dTop = null; if (barLength > 0.0) { bar3dRight = new GeneralPath(); bar3dRight.moveTo((float) x2, (float) y3); bar3dRight.lineTo((float) x2, (float) y1); bar3dRight.lineTo((float) x3, (float) y0); bar3dRight.lineTo((float) x3, (float) y2); bar3dRight.closePath(); if (itemPaint instanceof Color) { g2.setPaint(((Color) itemPaint).darker()); } else if (itemPaint instanceof GradientPaint) { GradientPaint gp = (GradientPaint) itemPaint; g2.setPaint(new StandardGradientPaintTransformer().transform(new GradientPaint(gp.getPoint1(), gp.getColor1().darker(), gp.getPoint2(), gp.getColor2().darker(), gp.isCyclic()), bar3dRight)); } g2.fill(bar3dRight); } bar3dTop = new GeneralPath(); bar3dTop.moveTo((float) x0, (float) y1); bar3dTop.lineTo((float) x1, (float) y0); bar3dTop.lineTo((float) x3, (float) y0); bar3dTop.lineTo((float) x2, (float) y1); bar3dTop.closePath(); g2.fill(bar3dTop); if (isDrawBarOutline() && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { g2.setStroke(getItemOutlineStroke(row, column)); g2.setPaint(getItemOutlinePaint(row, column)); g2.draw(bar); if (bar3dRight != null) { g2.draw(bar3dRight); } if (bar3dTop != null) { g2.draw(bar3dTop); } } CategoryItemLabelGenerator generator = getItemLabelGenerator(row, column); if (generator != null && isItemLabelVisible(row, column)) { drawItemLabel(g2, dataset, row, column, plot, generator, bar, (value < 0.0)); } // add an item entity, if this information is being collected EntityCollection entities = state.getEntityCollection(); if (entities != null) { GeneralPath barOutline = new GeneralPath(); barOutline.moveTo((float) x0, (float) y3); barOutline.lineTo((float) x0, (float) y1); barOutline.lineTo((float) x1, (float) y0); barOutline.lineTo((float) x3, (float) y0); barOutline.lineTo((float) x3, (float) y2); barOutline.lineTo((float) x2, (float) y3); barOutline.closePath(); addItemEntity(entities, dataset, row, column, barOutline); } }