/** * Creates a new TextElement without any additional filtering. * * @param name the name of the new element * @param bounds the bounds of the new element * @param paint the text color of this text element * @param alignment the horizontal text alignment. * @param valign the vertical alignment. * @param font the font for this element * @param nullString the text used when the value of this element is null * @param field the field in the datamodel to retrieve values from * @return a report element for displaying <code>String</code> objects. * @throws NullPointerException if bounds, name or function are null * @throws IllegalArgumentException if the given alignment is invalid * @deprecated Use a more fine-grained approach to define this element by using the * element-factory directly. */ public static Element createStringElement( final String name, final Rectangle2D bounds, final Color paint, final ElementAlignment alignment, final ElementAlignment valign, final FontDefinition font, final String nullString, final String field) { final TextFieldElementFactory factory = new TextFieldElementFactory(); factory.setX(new Float(bounds.getX())); factory.setY(new Float(bounds.getY())); factory.setMinimumWidth(new Float(bounds.getWidth())); factory.setMinimumHeight(new Float(bounds.getHeight())); factory.setName(name); factory.setColor(paint); factory.setHorizontalAlignment(alignment); factory.setVerticalAlignment(valign); if (font != null) { factory.setFontName(font.getFontName()); factory.setFontSize(new Integer(font.getFontSize())); factory.setBold(ElementFactory.getBooleanValue(font.isBold())); factory.setItalic(ElementFactory.getBooleanValue(font.isItalic())); factory.setEncoding(font.getFontEncoding(null)); factory.setUnderline(ElementFactory.getBooleanValue(font.isUnderline())); factory.setStrikethrough(ElementFactory.getBooleanValue(font.isStrikeThrough())); factory.setEmbedFont(ElementFactory.getBooleanValue(font.isEmbeddedFont())); } factory.setFieldname(field); factory.setNullString(nullString); return factory.createElement(); }
public void addSomeNodes(int num) { for (int i = 0; i < num; i++) { Node foo = factory.getNode(); foo.setId(idCounter++); ns.addDefaultNode(foo); } }
public Element createElement(String tagName) throws DOMException { return ElementFactory.createElement( this, NameImpl.getLocalNameFromTagName(tagName), NameImpl.getPrefixFromTagName(tagName), null); }
public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException { return ElementFactory.createElement( this, NameImpl.getLocalNameFromTagName(qualifiedName), NameImpl.getPrefixFromTagName(qualifiedName), namespaceURI); }
void init(Constructor constructor) { for (TypeVariable param : constructor.getTypeParameters()) { typeParameters.add(ElementFactory.getTypeParameterElement(param)); } type = TypeMirrorFactory.get(constructor); enclosingElement = ElementFactory.get(constructor.getDeclaringClass()); returnType = Typ.getNoType(TypeKind.VOID); Type[] genericParameterTypes = constructor.getGenericParameterTypes(); Annotation[][] parameterAnnotations = constructor.getParameterAnnotations(); int index = 0; for (Type param : genericParameterTypes) { parameters.add(ElementFactory.getVariableElement(param, parameterAnnotations[index++])); } varArgs = constructor.isVarArgs(); for (Type type : constructor.getGenericExceptionTypes()) { thrownTypes.add(TypeMirrorFactory.get(type)); } }
void init(Method method) { for (TypeVariable param : method.getTypeParameters()) { typeParameters.add(ElementFactory.getTypeParameterElement(param)); } type = TypeMirrorFactory.get(method); enclosingElement = ElementFactory.get(method.getDeclaringClass()); returnType = TypeMirrorFactory.get(method.getGenericReturnType()); Type[] genericParameterTypes = method.getGenericParameterTypes(); Annotation[][] parameterAnnotations = method.getParameterAnnotations(); int index = 0; for (Type param : genericParameterTypes) { parameters.add(ElementFactory.getVariableElement(param, parameterAnnotations[index++])); } varArgs = method.isVarArgs(); for (Type type : method.getGenericExceptionTypes()) { thrownTypes.add(TypeMirrorFactory.get(type)); } Object defValue = method.getDefaultValue(); if (defValue != null) { defaultValue = new AnnotationValueImpl(defValue); } }
/** * Creates an Image object. * * @param attrs properties of the Image * @return an Image object (or null if the Image couldn't be found) * @throws DocumentException * @throws IOException * @since 5.0.6 */ public Image createImage(final Map<String, String> attrs) throws DocumentException, IOException { String src = attrs.get(HtmlTags.SRC); if (src == null) return null; Image img = factory.createImage( src, attrs, chain, document, (ImageProvider) providers.get(IMG_PROVIDER), (ImageStore) providers.get(IMG_STORE), (String) providers.get(IMG_BASEURL)); return img; }
/** * Reads an individual Vertex from JSON. The vertex must match the accepted GraphSON format. * * @param node a single vertex in GraphSON format * @param factory the factory responsible for constructing graph elements * @param hasEmbeddedTypes the GraphSON has embedded types */ public static Vertex vertexFromJson( final JsonNode node, final ElementFactory factory, final boolean hasEmbeddedTypes) throws IOException { final Map<String, Object> props = readProperties(node, true, hasEmbeddedTypes); final Object vertexId = getTypedValueFromJsonNode(node.get(GraphSONTokens._ID)); final Vertex v = factory.createVertex(vertexId); for (Map.Entry<String, Object> entry : props.entrySet()) { v.setProperty(entry.getKey(), entry.getValue()); } return v; }
/** * Reads an individual Edge from JSON. The edge must match the accepted GraphSON format. * * @param node a single edge in GraphSON format * @param factory the factory responsible for constructing graph elements * @param hasEmbeddedTypes the GraphSON has embedded types */ public static Edge edgeFromJSON( final JsonNode node, final Vertex out, final Vertex in, final ElementFactory factory, final boolean hasEmbeddedTypes) throws IOException { final Map<String, Object> props = GraphSONFactory.readProperties(node, true, hasEmbeddedTypes); final Object edgeId = getTypedValueFromJsonNode(node.get(GraphSONTokens._ID)); final String label = node.get(GraphSONTokens._LABEL).getValueAsText(); final Edge e = factory.createEdge(edgeId, out, in, label); for (Map.Entry<String, Object> entry : props.entrySet()) { e.setProperty(entry.getKey(), entry.getValue()); } return e; }
public class TestBigNs { public static void main(String[] args) { new TestBigNs().test1(); } private NodeStructure ns; private static ElementFactory factory = ElementFactory.getInstance(); private int idCounter = 0; private int categoryIdCounter = 0; private Random random; private List<LinkCategory> linkCategoryPool = new ArrayList<LinkCategory>(); public void test1() { int seed = 23434535; random = new Random(seed); ns = new NodeStructureImpl(); int nodes = 10000; int linkCategories = 1000; double nodeLinkRatio = 5.0; int links = (int) (nodes / nodeLinkRatio); System.out.println("Creating NS with " + nodes + " nodes, " + links + " links"); createLinkCategoryPool(linkCategories); addSomeNodes(nodes); addSomeLinks(links); System.out.println("Copying NS\n"); long start = System.currentTimeMillis(); ns.copy(); long finish = System.currentTimeMillis(); System.out.println("time: " + (finish - start) + " ms"); System.out.println("ms per linkable : " + (finish - start) / (1.0 * ns.getLinkableCount())); System.out.println("total linkables " + ns.getLinkableCount()); } private void createLinkCategoryPool(int linkCategories) { for (int i = 0; i < linkCategories; i++) { PamNodeImpl temp = new PamNodeImpl(); temp.setId(categoryIdCounter++); linkCategoryPool.add(temp); } } public void addSomeNodes(int num) { for (int i = 0; i < num; i++) { Node foo = factory.getNode(); foo.setId(idCounter++); ns.addDefaultNode(foo); } } public void addSomeLinks(int num) { for (int i = 0; i < num; i++) { int randomSource = random.nextInt(idCounter); int randomSink = random.nextInt(idCounter); while (randomSink == randomSource) { randomSink = random.nextInt(idCounter); } Node source = ns.getNode(randomSource); Node sink = ns.getNode(randomSink); int randomCategory = random.nextInt(linkCategoryPool.size()); PamNode lcn = (PamNode) linkCategoryPool.get(randomCategory); lcn.setId(categoryIdCounter++); ns.addDefaultLink(source, sink, lcn, 1.0, -1.0); } } }
/** * Creates a LineSeparator object. * * @param attrs properties of the LineSeparator * @return a LineSeparator object * @since 5.0.6 */ public LineSeparator createLineSeparator(final Map<String, String> attrs) { return factory.createLineSeparator(attrs, currentParagraph.getLeading() / 2); }
/** * Creates a ListItem object. * * @return a ListItem object * @since 5.0.6 */ public ListItem createListItem() { return factory.createListItem(chain); }
/** * Creates a List object. * * @param tag should be "ol" or "ul" * @return a List object * @since 5.0.6 */ public com.itextpdf.text.List createList(final String tag) { return factory.createList(tag, chain); }
/** * Creates a Paragraph using the factory. * * @return a Paragraph without any content * @since 5.0.6 */ public Paragraph createParagraph() { return factory.createParagraph(chain); }
/** * Creates a Chunk using the factory. * * @param content the content of the chunk * @return a Chunk with content * @since 5.0.6 */ public Chunk createChunk(final String content) { return factory.createChunk(content, chain); }