/** * Constructor. */ public PDAnnotationPolygon() { getCOSObject().setName(COSName.SUBTYPE, SUB_TYPE); }
/** * This will retrieve the interior color. * * @return object representing the color. */ public PDColor getInteriorColor() { return getColor(COSName.IC); }
PDRectangle rect = annotation.getRectangle(); rect.setUpperRightX(Math.max(maxX + lineWidth, rect.getUpperRightX())); rect.setUpperRightY(Math.max(maxY + lineWidth, rect.getUpperRightY())); annotation.setRectangle(rect); .setNonStrokingColorOnDemand(annotation.getInteriorColor()); setOpacity(contentStream, annotation.getConstantOpacity()); contentStream.setBorderLine(lineWidth, annotation.getBorderStyle(), annotation.getBorder()); PDBorderEffectDictionary borderEffect = annotation.getBorderEffect(); if (borderEffect != null && borderEffect.getStyle().equals(PDBorderEffectDictionary.STYLE_CLOUDY)) borderEffect.getIntensity(), lineWidth, getRectangle()); cloudyBorder.createCloudyPolygon(pathArray); annotation.setRectangle(cloudyBorder.getRectangle()); PDAppearanceStream appearanceStream = annotation.getNormalAppearanceStream(); appearanceStream.setBBox(cloudyBorder.getBBox()); appearanceStream.setMatrix(cloudyBorder.getMatrix());
annotations.add(freeTextAnnotation); PDAnnotationPolygon polygon = new PDAnnotationPolygon(); position = new PDRectangle(); position.setLowerLeftX(pw - INCH); position.setUpperRightX(pw - 2 * INCH); position.setUpperRightY(ph - 2 * INCH); polygon.setRectangle(position); polygon.setColor(blue); polygon.setInteriorColor(green); float[] vertices = { pw - INCH, ph - 2 * INCH, pw - 1.5f * INCH, ph - INCH, pw - 2 * INCH, ph - 2 * INCH }; polygon.setVertices(vertices); polygon.setBorderStyle(borderThick); polygon.setContents("Polygon annotation"); annotations.add(polygon);
annot = new PDAnnotationPolygon(annotDic);
/** * This will set the border effect dictionary, specifying effects to be applied when drawing the * line. This is supported by PDF 1.5 and higher. * * @param be The border effect dictionary to set. * */ public void setBorderEffect(PDBorderEffectDictionary be) { getCOSObject().setItem(COSName.BE, be); }
/** * This will set interior color. * * @param ic color. */ public void setInteriorColor(PDColor ic) { getCOSObject().setItem(COSName.IC, ic.toCOSArray()); }
/** * This will retrieve the numbers that shall represent the alternating horizontal and vertical * coordinates. * * @return An array of floats representing the alternating horizontal and vertical coordinates. */ public float[] getVertices() { COSBase base = getCOSObject().getDictionaryObject(COSName.VERTICES); if (base instanceof COSArray) { return ((COSArray) base).toFloatArray(); } return null; }
/** * This will retrieve the border effect dictionary, specifying effects to be applied used in * drawing the line. * * @return The border effect dictionary */ public PDBorderEffectDictionary getBorderEffect() { COSDictionary be = (COSDictionary) getCOSObject().getDictionaryObject(COSName.BE); if (be != null) { return new PDBorderEffectDictionary(be); } else { return null; } }
/** * This will set the numbers that shall represent the alternating horizontal and vertical * coordinates. * * @param points an array with the numbers that shall represent the alternating horizontal and * vertical coordinates. */ public void setVertices(float[] points) { COSArray ar = new COSArray(); ar.setFloatArray(points); getCOSObject().setItem(COSName.VERTICES, ar); }
/** * PDF 2.0: This will retrieve the arrays that shall represent the alternating horizontal * and vertical coordinates for path building. * * @return An array of float arrays, each supplying the operands for a path building operator * (m, l or c). The first array should have 2 elements, the others should have 2 or 6 elements. */ public float[][] getPath() { COSBase base = getCOSObject().getDictionaryObject(COSName.PATH); if (base instanceof COSArray) { COSArray array = (COSArray) base; float[][] pathArray = new float[array.size()][]; for (int i = 0; i < array.size(); ++i) { COSBase base2 = array.getObject(i); if (base2 instanceof COSArray) { pathArray[i] = ((COSArray) array.getObject(i)).toFloatArray(); } else { pathArray[i] = new float[0]; } } return pathArray; } return null; }