Java Code Examples for java.awt.geom.GeneralPath#getCurrentPoint()
The following examples show how to use
java.awt.geom.GeneralPath#getCurrentPoint() .
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: CurveToReplicateInitialPoint.java From pdfxtk with Apache License 2.0 | 5 votes |
/** * process : v : Append curved segment to path (initial point replicated). * @param operator The operator that is being executed. * @param arguments List */ public void process(PDFOperator operator, List arguments) { PDFObjectExtractor drawer = (PDFObjectExtractor)context; COSNumber x2 = (COSNumber)arguments.get( 0 ); COSNumber y2 = (COSNumber)arguments.get( 1 ); COSNumber x3 = (COSNumber)arguments.get( 2 ); COSNumber y3 = (COSNumber)arguments.get( 3 ); GeneralPath path = drawer.getLinePath(); Point2D currentPoint = path.getCurrentPoint(); /* float x2f = x2.floatValue(); float y2f = (float)drawer.fixY( x2f, y2.floatValue() ); float x3f = x3.floatValue(); float y3f = (float)drawer.fixY( x3f, y3.floatValue() ); float currentX = (float)currentPoint.getX(); float currentY = (float)currentPoint.getY(); drawer.getLinePath().curveTo(currentX,currentY,x2f,y2f,x3f,y3f); */ Point2D P2 = drawer.TransformedPoint(x2.doubleValue(), y2.doubleValue()); Point2D P3 = drawer.TransformedPoint(x3.doubleValue(), y3.doubleValue()); drawer.getLinePath().curveTo((float)currentPoint.getX(), (float)currentPoint.getY(), (float)P2.getX(), (float)P2.getY(), (float)P3.getX(), (float)P3.getY()); drawer.simpleCurveTo((float)currentPoint.getX(), (float)currentPoint.getY(), (float)P2.getX(), (float)P2.getY(), (float)P3.getX(), (float)P3.getY()); }
Example 2
Source File: PDFObjectExtractor.java From pdfxtk with Apache License 2.0 | 5 votes |
/** * * Fill the path * * @param windingRule The winding rule this path will use. */ public void fillPath(int windingRule) throws IOException{ graphics.setColor( getGraphicsState().getNonStrokingColor().getJavaColor() ); //logger().info("Filling the path with rule: " + windingRule); getLinePath().setWindingRule(windingRule); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF ); List subPaths = getLineSubPaths(); for( int i=0; i<subPaths.size(); i++ ) { GeneralPath subPath = (GeneralPath)subPaths.get( i ); if (subPath.getCurrentPoint() != null){ //Sector9's suggestion in bug 1672556 subPath.closePath(); } /*Rectangle bBox = subPath.getBounds(); Point2D point1 = TransformedPoint(bBox.x, bBox.y); Point2D point2 = TransformedPoint(bBox.x + bBox.width, bBox.y + bBox.height); //RectSegment ls = new RectSegment(bBox.x, bBox.x*bBox.width, bBox.y, bBox.y+bBox.height); RectSegment ls = new RectSegment((float)point1.getX(), (float)point2.getX(), (float)point1.getY(), (float)point2.getY()); System.out.println("fillPath adding line segment: " + ls); rectList.add(ls);*/ graphics.fill( subPath ); } graphics.fill( getLinePath() ); getLinePath().reset();; }
Example 3
Source File: Graph.java From disthene-reader with MIT License | 4 votes |
private void drawLines(List<DecoratedTimeSeries> timeSeriesList) { Rectangle rectangle = new Rectangle(xMin, yMin, xMax - xMin + 1, yMax - yMin + 1); g2d.clip(rectangle); for (DecoratedTimeSeries ts : timeSeriesList) { g2d.setStroke(getStroke(ts)); g2d.setColor(getColor(ts)); GeneralPath path = new GeneralPath(); double x = xMin; int y; Double[] values = ts.getConsolidatedValues(); int consecutiveNulls = 0; boolean allNullsSoFar = true; for (Double value : values) { Double adjustedValue = value; if (adjustedValue == null && imageParameters.isDrawNullAsZero()) adjustedValue = 0.; if (adjustedValue == null) { /* if (consecutiveNulls == 0) { path.lineTo(x, y); } */ x += ts.getxStep(); consecutiveNulls++; continue; } if (secondYAxis) { if (ts.hasOption(TimeSeriesOption.SECOND_Y_AXIS)) { y = getYCoordRight(adjustedValue); } else { y = getYCoordLeft(adjustedValue); } } else { y = getYCoord(adjustedValue); } y = y < 0 ? 0 : y; if (path.getCurrentPoint() == null) { path.moveTo(x, y); } if (ts.hasOption(TimeSeriesOption.DRAW_AS_INFINITE) && adjustedValue > 0) { path.moveTo((int) x, yMax); path.lineTo((int) x, yMin); x += ts.getxStep(); continue; } if (imageParameters.getLineMode().equals(ImageParameters.LineMode.SLOPE)) { if (consecutiveNulls > 0) { path.moveTo(x, y); } path.lineTo(x, y); } else if (imageParameters.getLineMode().equals(ImageParameters.LineMode.STAIRCASE)) { if (consecutiveNulls > 0) { path.moveTo(x, y); } else { path.lineTo(x, y); } path.lineTo(x + ts.getxStep(), y); } else if (imageParameters.getLineMode().equals(ImageParameters.LineMode.CONNECTED)) { if (consecutiveNulls > imageParameters.getConnectedLimit() || allNullsSoFar) { path.moveTo(x, y); allNullsSoFar = false; } path.lineTo((int) x, y); } consecutiveNulls = 0; x += ts.getxStep(); } g2d.draw(path); } }