public virtual void paintComponent(Graphics g) { Graphics2D graphics2D = (Graphics2D) g; Dimension size = ((Component) this).getSize(); Insets insets = this.getInsets(); Rectangle2D.Double @double = new Rectangle2D.Double((double) insets.left, (double) insets.top, size.getWidth() - (double) insets.left - (double) insets.right - 1.0, size.getHeight() - (double) insets.top - (double) insets.bottom - 1.0); graphics2D.setPaint(this.paint); graphics2D.fill((Shape) @double); graphics2D.setPaint((Paint) Color.black); graphics2D.draw((Shape) @double); }
private Rectangle2D generateBoundingRect(ISet <GeoPosition> paramSet, int paramInt) { Point2D point2D = TileFactory.geoToPixel((GeoPosition)paramSet.GetEnumerator().next(), paramInt); Rectangle2D.Double double = new Rectangle2D.Double(point2D.X, point2D.Y, 0.0D, 0.0D); foreach (GeoPosition geoPosition in paramSet) { Point2D point2D1 = TileFactory.geoToPixel(geoPosition, paramInt); double.add(point2D1); } return(double); }
private void setPaint(Paint paint, boolean invert, double xoffset, double yoffset) { this.paint = paint; if (paint is Color) { cb.setColorFill((Color)paint); } else if (paint is GradientPaint) { GradientPaint gp = (GradientPaint)paint; Point2D p1 = gp.getPoint1(); transform.transform(p1, p1); Point2D p2 = gp.getPoint2(); transform.transform(p2, p2); Color c1 = gp.getColor1(); Color c2 = gp.getColor2(); PdfShading shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float)p1.getX(), (float)p1.getY(), (float)p2.getX(), (float)p2.getY(), c1, c2); PdfShadingPattern pat = new PdfShadingPattern(shading); cb.setShadingFill(pat); } else { try { BufferedImage img = null; int type = BufferedImage.TYPE_4BYTE_ABGR; if (paint.getTransparency() == Transparency.OPAQUE) { type = BufferedImage.TYPE_3BYTE_BGR; } img = new BufferedImage((int)width, (int)height, type); Graphics2D g = (Graphics2D)img.getGraphics(); Shape fillRect = new Rectangle2D.Double(0, 0, img.getWidth(), img.getHeight()); g.setPaint(paint); g.fill(fillRect); if (invert) { AffineTransform tx = new AffineTransform(); tx.scale(1, -1); tx.translate(-xoffset, -yoffset); g.drawImage(img, tx, null); } com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(img, null); PdfPatternPainter pattern = cb.createPattern(width, height); image.setAbsolutePosition(0, 0); pattern.addImage(image); cb.setPatternFill(pattern); } catch (Exception ex) { cb.setColorFill(Color.gray); } } }
public Rectangle2D GetLogicalAnchor2D() { Rectangle anchor = GetAnchor2D(); //if it is a groupped shape see if we need to transform the coordinates if (_parent != null) { Shape top = _parent; while (top.GetParent() != null) { top = top.GetParent(); } Rectangle clientAnchor = top.GetAnchor2D(); Rectangle spgrAnchor = ((ShapeGroup)top).GetCoordinates(); double scalex = spgrAnchor.Width / clientAnchor.Width; double scaley = spgrAnchor.Height / clientAnchor.Height; double x = clientAnchor.X + (anchor.X - spgrAnchor.X) / scalex; double y = clientAnchor.Y + (anchor.Y - spgrAnchor.Y) / scaley; double width = anchor.Width / scalex; double height = anchor.Height / scaley; anchor = new Rectangle2D.Double(x, y, width, height); } int angle = GetRotation(); if (angle != 0) { double centerX = anchor.X + anchor.Width / 2; double centerY = anchor.Y + anchor.Height / 2; AffineTransform trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.ToRadians(angle)); trans.translate(-centerX, -centerY); Rectangle2D rect = trans.CreateTransformedShape(anchor).GetBounds2D(); if ((anchor.Width < anchor.Height && rect.Width > rect.Height) || (anchor.Width > anchor.Height && rect.Width < rect.Height)) { trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.PI / 2); trans.translate(-centerX, -centerY); anchor = trans.CreateTransformedShape(anchor).GetBounds2D(); } } return(anchor); }
internal virtual void calculateBounds(double[] paramArrayOfDouble1, double[] paramArrayOfDouble2, int paramInt) { double d1 = double.MaxValue; double d2 = double.MaxValue; double d3 = double.Epsilon; double d4 = double.Epsilon; for (sbyte b = 0; b < paramInt; b++) { double d5 = paramArrayOfDouble1[b]; d1 = Math.Min(d1, d5); d3 = Math.Max(d3, d5); double d6 = paramArrayOfDouble2[b]; d2 = Math.Min(d2, d6); d4 = Math.Max(d4, d6); } this.bounds2d = new Rectangle2D.Double(d1, d2, d3 - d1, d4 - d2); this.bounds = new Rectangle((int)Math.Floor(d1), (int)Math.Floor(d2), (int)Math.Ceiling(d3 - d1), (int)Math.Ceiling(d4 - d2)); }
internal string GetTextByArea(PDDocument pdfDocument, double X, double Y, double width, double height, int pageNumber) { string empty; try { PDFHelper.DisplayTrialPopupIfNecessary(); string str = string.Empty; if (PDFHelper.AddStamp) { str = string.Concat(str, "You are using a trial license of PDF Toolkit, as a result only the first three pages would be extracted."); } if ((width <= 0 ? true : height <= 0)) { Console.WriteLine("Sorry the length and width you provided are not greater than zero, no text will be extracted."); str = string.Empty; } else { PDPage page = pdfDocument.getPage(pageNumber - 1); string str1 = "region"; Rectangle2D num = new Rectangle2D.Double(X, Y, width, height); PDFTextStripperByArea pDFTextStripperByArea = new PDFTextStripperByArea(); pDFTextStripperByArea.addRegion(str1, num); pDFTextStripperByArea.extractRegions(page); str = string.Concat(str, pDFTextStripperByArea.getTextForRegion(str1).Replace("\r", string.Empty).Replace("\n", string.Empty)); } empty = str; } catch (Exception exception) { Console.WriteLine("Sorry an exception occured when the text was being extracted\n{0}", exception.Message); empty = string.Empty; } return(empty); }
public override void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { Number number1 = dataset.getValue(row, column); if (number1 == null) return; double categoryMiddle1 = domainAxis.getCategoryMiddle(column, this.getColumnCount(), dataArea, plot.getDomainAxisEdge()); double num1 = rangeAxis.valueToJava2D(number1.doubleValue(), dataArea, plot.getRangeAxisEdge()); g2.setPaint(this.getItemPaint(row, column)); g2.setStroke(this.getItemStroke(row, column)); Rectangle2D.Double double1 = new Rectangle2D.Double(categoryMiddle1 - 4.0, num1 - 4.0, 8.0, 8.0); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) this.objectIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(categoryMiddle1), ByteCodeHelper.d2i(num1)); else this.objectIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(num1), ByteCodeHelper.d2i(categoryMiddle1)); if (this.lastCategory == column) { if (this.min > number1.doubleValue()) this.min = number1.doubleValue(); if (this.max < number1.doubleValue()) this.max = number1.doubleValue(); if (dataset.getRowCount() - 1 == row) { g2.setPaint(this.groupPaint); g2.setStroke(this.groupStroke); double num2 = rangeAxis.valueToJava2D(this.min, dataArea, plot.getRangeAxisEdge()); double num3 = rangeAxis.valueToJava2D(this.max, dataArea, plot.getRangeAxisEdge()); if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) { g2.draw((Shape) new Line2D.Double(categoryMiddle1, num2, categoryMiddle1, num3)); this.minIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(categoryMiddle1), ByteCodeHelper.d2i(num2)); this.maxIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(categoryMiddle1), ByteCodeHelper.d2i(num3)); } else { g2.draw((Shape) new Line2D.Double(num2, categoryMiddle1, num3, categoryMiddle1)); this.minIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(num2), ByteCodeHelper.d2i(categoryMiddle1)); this.maxIcon.paintIcon((Component) null, (Graphics) g2, ByteCodeHelper.d2i(num3), ByteCodeHelper.d2i(categoryMiddle1)); } } } else { this.lastCategory = column; this.min = number1.doubleValue(); this.max = number1.doubleValue(); } if (this.plotLines && column != 0) { Number number2 = dataset.getValue(row, column - 1); if (number2 != null) { double d = number2.doubleValue(); double categoryMiddle2 = domainAxis.getCategoryMiddle(column - 1, this.getColumnCount(), dataArea, plot.getDomainAxisEdge()); double num2 = rangeAxis.valueToJava2D(d, dataArea, plot.getRangeAxisEdge()); g2.setPaint(this.getItemPaint(row, column)); g2.setStroke(this.getItemStroke(row, column)); Line2D.Double double2 = orientation != PlotOrientation.__\u003C\u003EVERTICAL ? new Line2D.Double(num2, categoryMiddle2, num1, categoryMiddle1) : new Line2D.Double(categoryMiddle2, num2, categoryMiddle1, num1); g2.draw((Shape) double2); } } EntityCollection entityCollection = state.getEntityCollection(); if (entityCollection == null || double1 == null) return; this.addItemEntity(entityCollection, dataset, row, column, (Shape) double1); }
/** * Get the nearest node to the mouse cursor position. * @param w Canvas width. * @param h Canvas height. * @param x Mouse x position. * @param y Mouse y position. * @param net Epanet network. * @return Reference to the nearest node. */ public static Node peekNearest(int w, int h, int x, int y, Network net) { if (net == null) { return(null); } Rectangle2D.Double bounds = null; foreach (Node node in net.getNodes()) { if (node.getPosition() != null) { if (bounds == null) { bounds = new Rectangle2D.Double((int)node.getPosition().getX(), (int)-node.getPosition().getY(), 0, 0); } else { bounds.add(new java.awt.Point((int)node.getPosition().getX(), (int)-node.getPosition().getY())); } } } foreach (Link link in net.getLinks()) { //java.util.List<org.addition.epanetold.Types.Point> vertices = link.getVertices(); foreach (Point position in link.getVertices()) { if (position != null) { if (bounds == null) { bounds = new Rectangle2D.Double((int)position.getX(), (int)-position.getY(), 0, 0); } else { bounds.add(new java.awt.Point((int)position.getX(), (int)-position.getY())); } } } } double factor = (bounds.width / bounds.height) < (((double)w) / h) ? h / bounds.height : w / bounds.width; double dx = bounds.getMinX(); double dy = bounds.getMinY(); double dwidth = Math.Abs(bounds.getMaxX() - bounds.getMinX()); double dheight = Math.Abs(bounds.getMaxY() - bounds.getMinY()); factor *= .9d; dx += dwidth * .5d - w * 0.5 / factor; dy += dheight * .5d - h * 0.5 / factor; Node nearest = null; double distance = 0; foreach (Node n in net.getNodes()) { Point point = new Point( (int)((n.getPosition().getX() - dx) * factor), (int)((-n.getPosition().getY() - dy) * factor)); double dist = Math.Sqrt(Math.Pow(point.getX() - x, 2) + Math.pow(point.getY() - y, 2)); if (nearest == null || dist < distance) { nearest = n; distance = dist; } } return(nearest); }
/** * Render the network in the canvas. * @param g Reference to the canvas graphics. * @param w Canvas width. * @param h Canvas height. * @param net Epanet network. * @param drawPipes Draw pipes flag. * @param drawTanks Draw tanks flag. * @param drawNodes Draw nodes flag. * @param selNode Reference to the selected node. */ public static void drawNetwork(Graphics g, int w, int h, Network net, bool drawPipes, bool drawTanks, bool drawNodes, Node selNode) { //int maxNodes = net.getMaxNodes(); //int maxLinks = net.getMaxLinks(); Rectangle2D.Double bounds = null; foreach (Node node in net.getNodes()) { if (node.getPosition() != null) { if (bounds == null) { bounds = new Rectangle2D.Double((int)node.getPosition().getX(), (int)-node.getPosition().getY(), 0, 0); } else { bounds.add(new java.awt.Point((int)node.getPosition().getX(), (int)-node.getPosition().getY())); } } } foreach (Link link in net.getLinks()) { //java.util.List<org.addition.epanetold.Types.Point> vertices = link.getVertices(); foreach (Point position in link.getVertices()) { if (position != null) { if (bounds == null) { bounds = new Rectangle2D.Double((int)position.getX(), (int)-position.getY(), 0, 0); } else { bounds.add(new java.awt.Point((int)position.getX(), (int)-position.getY())); } } } } ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //g.setColor(new Color(0x99, 0x99, 0x99)); //g.drawRect(0, 0, w - 1, h - 1); double factor = (bounds.width / bounds.height) < (((double)w) / h) ? h / bounds.height : w / bounds.width; double dx = bounds.getMinX(); double dy = bounds.getMinY(); double dwidth = Math.Abs(bounds.getMaxX() - bounds.getMinX()); double dheight = Math.Abs(bounds.getMaxY() - bounds.getMinY()); factor *= .9d; dx += dwidth * .5d - w * 0.5 / factor; dy += dheight * .5d - h * 0.5 / factor; //tanks if (drawTanks) { foreach (Tank tank in net.getTanks()) { if (tank.getArea() == 0) { // Reservoir Point position = tank.getPosition(); if (position != null) { Point point = new Point( (int)((position.getX() - dx) * factor), (int)((-position.getY() - dy) * factor)); g.setColor(RESERVOIRS_FILL_COLOR); g.fillRect((int)(point.getX() - RESERVOIR_DIAM / 2), (int)(point.getY() - RESERVOIR_DIAM / 2), RESERVOIR_DIAM, RESERVOIR_DIAM); g.setColor(RESERVOIRS_STROKE_COLOR); g.drawRect((int)(point.getX() - RESERVOIR_DIAM / 2), (int)(point.getY() - RESERVOIR_DIAM / 2), RESERVOIR_DIAM, RESERVOIR_DIAM); } } else { // Tank Point position = tank.getPosition(); if (position != null) { Point point = new Point( (int)((position.getX() - dx) * factor), (int)((-position.getY() - dy) * factor)); g.setColor(TANKS_FILL_COLOR); g.fillRect((int)(point.getX() - RESERVOIR_DIAM / 2), (int)(point.getY() - RESERVOIR_DIAM / 2), TANK_DIAM, TANK_DIAM); g.setColor(TANKS_STROKE_COLOR); g.drawRect((int)(point.getX() - RESERVOIR_DIAM / 2), (int)(point.getY() - RESERVOIR_DIAM / 2), TANK_DIAM, TANK_DIAM); } } } } if (drawPipes) { //links g.setColor(PIPES_FILL_COLOR); foreach (Link link in net.getLinks()) { List <Point> vertices = new ArrayList <Point>(link.getVertices()); Node node1 = link.getFirst(); Node node2 = link.getSecond(); vertices.add(0, node1.getPosition()); vertices.add(node2.getPosition()); Point prev = null; foreach (Point position in vertices) { Point point = new Point( (int)((position.getX() - dx) * factor), (int)((-position.getY() - dy) * factor)); if (prev != null) { g.drawLine((int)prev.getX(), (int)prev.getY(), (int)point.getX(), (int)point.getY()); } prev = point; } } } if (drawNodes) { //nodes Color nodefillColor = NODE_FILL_COLOR; Color nodeStrokeColor = NODE_STROKE_COLOR; g.setColor(nodefillColor); foreach (Node node in net.getNodes()) { Point position = node.getPosition(); if (position != null) { Point point = new Point( (int)((position.getX() - dx) * factor), (int)((-position.getY() - dy) * factor)); g.setColor(nodefillColor); g.fillOval((int)(point.getX() - NODE_DIAM / 2), (int)(point.getY() - NODE_DIAM / 2), NODE_DIAM, NODE_DIAM); g.setColor(nodeStrokeColor); g.drawOval((int)(point.getX() - NODE_DIAM / 2), (int)(point.getY() - NODE_DIAM / 2), NODE_DIAM, NODE_DIAM); } } } foreach (Label l in net.getLabels()) { Point point = new Point( (int)((l.getPosition().getX() - dx) * factor), (int)((-l.getPosition().getY() - dy) * factor)); g.setColor(LABEL_COLOR); g.drawString(l.getText(), (int)point.getX(), (int)point.getY()); } if (selNode != null) { Point point = new Point( (int)((selNode.getPosition().getX() - dx) * factor), (int)((-selNode.getPosition().getY() - dy) * factor)); g.setColor(new Color(0xFF0000)); g.drawOval((int)(point.getX() - 20 / 2), (int)(point.getY() - 20 / 2), 20, 20); g.setColor(LABEL_COLOR); g.drawString(selNode.getId(), (int)point.getX() + 20, (int)point.getY() + 20); } }
protected internal virtual void drawInterval(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, IntervalCategoryDataset dataset, int row, int column) { int visibleSeriesIndex = state.getVisibleSeriesIndex(row); if (visibleSeriesIndex < 0) return; int num1 = state.getVisibleSeriesCount() < 0 ? this.getRowCount() : state.getVisibleSeriesCount(); int columnCount = this.getColumnCount(); PlotOrientation orientation = plot.getOrientation(); double num2 = 0.0; double num3 = 0.0; RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); Number endValue = dataset.getEndValue(row, column); if (endValue == null) return; double num4 = rangeAxis.valueToJava2D(endValue.doubleValue(), dataArea, rangeAxisEdge); Number startValue = dataset.getStartValue(row, column); if (startValue == null) return; double num5 = rangeAxis.valueToJava2D(startValue.doubleValue(), dataArea, rangeAxisEdge); if (num5 < num4) { double num6 = num5; num5 = num4; num4 = num6; } double num7 = state.getBarWidth(); double num8 = Math.abs(num5 - num4); RectangleEdge re = RectangleEdge.__\u003C\u003ELEFT; if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL) { double categoryStart = domainAxis.getCategoryStart(column, this.getColumnCount(), dataArea, domainAxisEdge); if (num1 > 1) { double num6 = ((RectangularShape) dataArea).getHeight() * this.getItemMargin() / (double) (columnCount * (num1 - 1)); num3 = categoryStart + (double) visibleSeriesIndex * (state.getBarWidth() + num6); } else num3 = categoryStart + (double) visibleSeriesIndex * state.getBarWidth(); num2 = num4; num8 = state.getBarWidth(); num7 = Math.abs(num5 - num4); re = RectangleEdge.__\u003C\u003ELEFT; } else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) { double categoryStart = domainAxis.getCategoryStart(column, this.getColumnCount(), dataArea, domainAxisEdge); if (num1 > 1) { double num6 = ((RectangularShape) dataArea).getWidth() * this.getItemMargin() / (double) (columnCount * (num1 - 1)); num2 = categoryStart + (double) visibleSeriesIndex * (state.getBarWidth() + num6); } else num2 = categoryStart + (double) visibleSeriesIndex * state.getBarWidth(); num3 = num4; re = RectangleEdge.__\u003C\u003EBOTTOM; } Rectangle2D.Double @double = new Rectangle2D.Double(num2, num3, num7, num8); BarPainter barPainter = this.getBarPainter(); if (this.getShadowsVisible()) barPainter.paintBarShadow(g2, (BarRenderer) this, row, column, (RectangularShape) @double, re, false); this.getBarPainter().paintBar(g2, (BarRenderer) this, row, column, (RectangularShape) @double, re); CategoryItemLabelGenerator itemLabelGenerator = this.getItemLabelGenerator(row, column); if (itemLabelGenerator != null && this.isItemLabelVisible(row, column)) this.drawItemLabel(g2, (CategoryDataset) dataset, row, column, plot, itemLabelGenerator, (Rectangle2D) @double, false); EntityCollection entityCollection = state.getEntityCollection(); if (entityCollection == null) return; this.addItemEntity(entityCollection, (CategoryDataset) dataset, row, column, (Shape) @double); }
public override void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!(dataset is IntervalXYDataset) || !(dataset is TableXYDataset)) { string str1 = new StringBuffer().append("dataset (type ").append(Object.instancehelper_getClass((object) dataset).getName()).append(") has wrong type:").toString(); int num = 0; if (!(StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset != null ? StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset : (StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset = StackedXYBarRenderer.class\u0024("org.jfree.data.xy.IntervalXYDataset"))).isAssignableFrom(Object.instancehelper_getClass((object) dataset))) { str1 = new StringBuffer().append(str1).append(" it is no IntervalXYDataset").toString(); num = 1; } if (!(StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset != null ? StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset : (StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset = StackedXYBarRenderer.class\u0024("org.jfree.data.xy.TableXYDataset"))).isAssignableFrom(Object.instancehelper_getClass((object) dataset))) { if (num != 0) str1 = new StringBuffer().append(str1).append(" and").toString(); str1 = new StringBuffer().append(str1).append(" it is no TableXYDataset").toString(); } string str2 = str1; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str2); } else { IntervalXYDataset ntervalXyDataset = (IntervalXYDataset) dataset; double yvalue1 = ntervalXyDataset.getYValue(series, item); if (Double.isNaN(yvalue1)) return; double num1 = 0.0; if (this.renderAsPercentages) { num1 = DatasetUtilities.calculateStackTotal((TableXYDataset) dataset, item); yvalue1 /= num1; } double d1 = 0.0; double d2 = 0.0; for (int i1 = 0; i1 < series; ++i1) { double yvalue2 = dataset.getYValue(i1, item); if (!Double.isNaN(yvalue2)) { if (this.renderAsPercentages) yvalue2 /= num1; if (yvalue2 > 0.0) d1 += yvalue2; else d2 += yvalue2; } } RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double num2; double num3; if (yvalue1 > 0.0) { num2 = rangeAxis.valueToJava2D(d1, dataArea, rangeAxisEdge); num3 = rangeAxis.valueToJava2D(d1 + yvalue1, dataArea, rangeAxisEdge); } else { num2 = rangeAxis.valueToJava2D(d2, dataArea, rangeAxisEdge); num3 = rangeAxis.valueToJava2D(d2 + yvalue1, dataArea, rangeAxisEdge); } RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); double startXvalue = ntervalXyDataset.getStartXValue(series, item); if (Double.isNaN(startXvalue)) return; double num4 = domainAxis.valueToJava2D(startXvalue, dataArea, domainAxisEdge); double endXvalue = ntervalXyDataset.getEndXValue(series, item); if (Double.isNaN(endXvalue)) return; double num5 = domainAxis.valueToJava2D(endXvalue, dataArea, domainAxisEdge); double num6 = Math.max(1.0, Math.abs(num5 - num4)); double num7 = Math.abs(num3 - num2); if (this.getMargin() > 0.0) { double num8 = num6 * this.getMargin(); num6 -= num8; num4 += num8 / 2.0; } Rectangle2D.Double @double = (Rectangle2D.Double) null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL) @double = new Rectangle2D.Double(Math.min(num2, num3), num5, num7, num6); else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) @double = new Rectangle2D.Double(num4, Math.min(num2, num3), num6, num7); int num9 = yvalue1 > 0.0 ? 1 : 0; int num10 = rangeAxis.isInverted() ? 1 : 0; RectangleEdge re = orientation != PlotOrientation.__\u003C\u003EHORIZONTAL ? (num9 != 0 && num10 == 0 || num9 == 0 && num10 != 0 ? RectangleEdge.__\u003C\u003EBOTTOM : RectangleEdge.__\u003C\u003ETOP) : (num9 != 0 && num10 != 0 || num9 == 0 && num10 == 0 ? RectangleEdge.__\u003C\u003ERIGHT : RectangleEdge.__\u003C\u003ELEFT); if (pass == 0) { if (!this.getShadowsVisible()) return; this.getBarPainter().paintBarShadow(g2, (XYBarRenderer) this, series, item, (RectangularShape) @double, re, false); } else if (pass == 1) { this.getBarPainter().paintBar(g2, (XYBarRenderer) this, series, item, (RectangularShape) @double, re); if (info == null) return; EntityCollection entityCollection = info.getOwner().getEntityCollection(); if (entityCollection == null) return; this.addEntity(entityCollection, (Shape) @double, dataset, series, item, ((RectangularShape) @double).getCenterX(), ((RectangularShape) @double).getCenterY()); } else { if (pass != 2 || !this.isItemLabelVisible(series, item)) return; XYItemLabelGenerator itemLabelGenerator = this.getItemLabelGenerator(series, item); this.drawItemLabel(g2, dataset, series, item, plot, itemLabelGenerator, (Rectangle2D) @double, yvalue1 < 0.0); } } }
/** * @see Graphics#setClip(int, int, int, int) */ public void setClip(int x, int y, int width, int height) { Rectangle2D rect = new Rectangle2D.Double(x, y, width, height); setClip(rect); }
public static Rectangle2D drawAlignedString(string text, Graphics2D g2, float x, float y, TextAnchor anchor) { Rectangle2D.Double @double = new Rectangle2D.Double(); float[] numArray = TextUtilities.deriveTextBoundsAnchorOffsets(g2, text, anchor, (Rectangle2D) @double); ((Rectangle2D) @double).setRect((double) (x + numArray[0]), (double) (y + numArray[1] + numArray[2]), ((RectangularShape) @double).getWidth(), ((RectangularShape) @double).getHeight()); g2.drawString(text, x + numArray[0], y + numArray[1]); return (Rectangle2D) @double; }
public Rectangle2D GetLogicalAnchor2D() { Rectangle anchor = GetAnchor2D(); //if it is a groupped shape see if we need to transform the coordinates if (_parent != null) { Shape top = _parent; while (top.GetParent() != null) top = top.GetParent(); Rectangle clientAnchor = top.GetAnchor2D(); Rectangle spgrAnchor = ((ShapeGroup)top).GetCoordinates(); double scalex = spgrAnchor.Width / clientAnchor.Width; double scaley = spgrAnchor.Height / clientAnchor.Height; double x = clientAnchor.X + (anchor.X - spgrAnchor.X) / scalex; double y = clientAnchor.Y + (anchor.Y - spgrAnchor.Y) / scaley; double width = anchor.Width / scalex; double height = anchor.Height / scaley; anchor = new Rectangle2D.Double(x, y, width, height); } int angle = GetRotation(); if (angle != 0) { double centerX = anchor.X + anchor.Width / 2; double centerY = anchor.Y + anchor.Height / 2; AffineTransform trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.ToRadians(angle)); trans.translate(-centerX, -centerY); Rectangle2D rect = trans.CreateTransformedShape(anchor).GetBounds2D(); if ((anchor.Width < anchor.Height && rect.Width > rect.Height) || (anchor.Width > anchor.Height && rect.Width < rect.Height)) { trans = new AffineTransform(); trans.translate(centerX, centerY); trans.rotate(Math.PI / 2); trans.translate(-centerX, -centerY); anchor = trans.CreateTransformedShape(anchor).GetBounds2D(); } } return anchor; }
public virtual LegendItemCollection getLegendCollection() { LegendItemCollection legendItemCollection = new LegendItemCollection(); if (this.paintIndex != null && this.paintIndex.size() > 0) { if (this.paintIndex.size() <= this.paintLimit) { Iterator iterator = this.paintIndex.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); string label = Object.instancehelper_toString(entry.getKey()); string description = label; Rectangle2D.Double @double = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); Paint fillPaint = this.lookupSeriesPaint(((Integer) entry.getValue()).intValue()); Color color = (Color) Color.black; Stroke outlineStroke = AbstractRenderer.__\u003C\u003EDEFAULT_STROKE; legendItemCollection.add(new LegendItem(label, description, (string) null, (string) null, (Shape) @double, fillPaint, outlineStroke, (Paint) color)); } } else { HashSet hashSet = new HashSet(); Iterator iterator = this.paintIndex.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); if (((Set) hashSet).add(entry.getValue())) { string label = new StringBuffer().append(Object.instancehelper_toString((object) this.getMinPaintValue((Integer) entry.getValue()))).append(" - ").append(Object.instancehelper_toString((object) this.getMaxPaintValue((Integer) entry.getValue()))).toString(); string description = label; Rectangle2D.Double @double = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); Paint seriesPaint = this.getSeriesPaint(((Integer) entry.getValue()).intValue()); Color color = (Color) Color.black; Stroke outlineStroke = AbstractRenderer.__\u003C\u003EDEFAULT_STROKE; legendItemCollection.add(new LegendItem(label, description, (string) null, (string) null, (Shape) @double, seriesPaint, outlineStroke, (Paint) color)); } } } } return legendItemCollection; }