Package org.jfree.report.structure

Examples of org.jfree.report.structure.Element


      if (cellController == null)
      {
        Log.warn("Image is not contained in a table. Unable to calculate the image-size.");
        return null;
      }
      final Element tableCell = (Element) cellController.getNode();
      final int rowSpan = TextUtilities.parseInt
          ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-rows-spanned"), 1);
      final int colSpan = TextUtilities.parseInt
          ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"), 1);
      if (rowSpan < 1 || colSpan < 1)
      {
        Log.warn("Rowspan or colspan for image-size calculation was invalid.");
        return null;
      }

      final LayoutController rowController = cellController.getParent();
      if (rowController == null)
      {
        Log.warn("Table-Cell has no parent. Unable to calculate the image-size.");
        return null;
      }
      final Section tableRow = (Section) rowController.getNode();
      // we are now making the assumption, that the row is a section, that contains the table-cell.
      // This breaks the ability to return nodes or to construct reports on the fly, but the OO-report format
      // is weird anyway and wont support such advanced techniques for the next few centuries ..
      final int columnPos = findNodeInSection(tableRow, tableCell,"covered-table-cell");
      if (columnPos == -1)
      {
        Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size.");
        return null;
      }

      final LayoutController tableController = rowController.getParent();
      if (tableController == null)
      {
        Log.warn("Table-Row has no Table. Unable to calculate the image-size.");
        return null;
      }

      final Section table = (Section) tableController.getNode();
      // ok, we got a table, so as next we have to search for the columns now.
      final Section columns = (Section) table.findFirstChild(OfficeNamespaces.TABLE_NS, "table-columns");
      if (columns.getNodeCount() <= columnPos + colSpan)
      {
        // the colspan is to large. The table definition is therefore invalid. We do not try to fix this.
        Log.warn(
            "The Table's defined columns do not match the col-span or col-position. Unable to calculate the image-size.");
        return null;
      }

      final ImageElementContext context = new ImageElementContext(colSpan, rowSpan);

      final Node[] columnDefs = columns.getNodeArray();
      int columnCounter = 0;
      for (int i = 0; i < columnDefs.length; i++)
      {
        final Element column = (Element) columnDefs[i];

        if (ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS) == false ||
            ObjectUtilities.equal(column.getType(), "table-column") == false)
        {
          continue;
        }
        if (columnCounter >= columnPos)
        {
          final String colStyle = (String) column.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
          context.setColStyle(columnCounter - columnPos, colStyle);
        }

        columnCounter += 1;

        if (columnCounter >= (columnPos + colSpan))
        {
          break;
        }

      }

      // finally search the styles for the row now.
      final int rowPos = findNodeInSection(table, tableRow,null);
      if (rowPos == -1)
      {
        Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size.");
        return null;
      }

      final Node[] rows = table.getNodeArray();
      int rowCounter = 0;
      for (int i = 0; i < rows.length; i++)
      {
        final Element row = (Element) rows[i];

        if (ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS) == false ||
            ObjectUtilities.equal(row.getType(), "table-row") == false)
        {
          continue;
        }
        if (rowCounter >= rowPos)
        {
          final String rowStyle = (String) row.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
          context.setRowStyle(rowCounter - rowPos, rowStyle);
        }

        rowCounter += 1;
View Full Code Here


      final Node node = nodes[i];
      if (node instanceof Element == false)
      {
        continue;
      }
      final Element child = (Element) node;
/*
      if (! "covered-table-cell".equals(child.getType()) &&
              (ObjectUtilities.equal(child.getNamespace(), namespace) == false ||
                ObjectUtilities.equal(child.getType(), type) == false))
*/
      if (ObjectUtilities.equal(child.getNamespace(), namespace) == false ||
          (ObjectUtilities.equal(child.getType(), type) == false
              && (secondType == null || ObjectUtilities.equal(child.getType(), secondType) == false)) )
      {
        continue;
      }

      if (node == tableCell)
View Full Code Here

    while (parent != null)
    {
      final Object node = parent.getNode();
      if (node instanceof Element)
      {
        final Element element = (Element) node;
        if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && "table-cell".equals(element.getType()))
        {
          return parent;
        }
      }
      parent = parent.getParent();
View Full Code Here

      if (node instanceof Element == false)
      {
        continue;
      }

      final Element element = (Element) node;
      if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) &&
          "table".equals(element.getType()))
      {
        tables.add(element);
      }
    }
  }
View Full Code Here

      if (cellController == null)
      {
        Log.warn("Image is not contained in a table. Unable to calculate the image-size.");
        return null;
      }
      final Element tableCell = (Element) cellController.getNode();
      final int rowSpan = TextUtilities.parseInt
          ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-rows-spanned"), 1);
      final int colSpan = TextUtilities.parseInt
          ((String) tableCell.getAttribute(OfficeNamespaces.TABLE_NS, "number-columns-spanned"), 1);
      if (rowSpan < 1 || colSpan < 1)
      {
        Log.warn("Rowspan or colspan for image-size calculation was invalid.");
        return null;
      }

      final LayoutController rowController = cellController.getParent();
      if (rowController == null)
      {
        Log.warn("Table-Cell has no parent. Unable to calculate the image-size.");
        return null;
      }
      final Section tableRow = (Section) rowController.getNode();
      // we are now making the assumption, that the row is a section, that contains the table-cell.
      // This breaks the ability to return nodes or to construct reports on the fly, but the OO-report format
      // is weird anyway and wont support such advanced techniques for the next few centuries ..
      final int columnPos = findNodeInSection(tableRow, tableCell,"covered-table-cell");
      if (columnPos == -1)
      {
        Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size.");
        return null;
      }

      final LayoutController tableController = rowController.getParent();
      if (tableController == null)
      {
        Log.warn("Table-Row has no Table. Unable to calculate the image-size.");
        return null;
      }

      final Section table = (Section) tableController.getNode();
      // ok, we got a table, so as next we have to search for the columns now.
      final Section columns = (Section) table.findFirstChild(OfficeNamespaces.TABLE_NS, "table-columns");
      if (columns.getNodeCount() <= columnPos + colSpan)
      {
        // the colspan is to large. The table definition is therefore invalid. We do not try to fix this.
        Log.warn(
            "The Table's defined columns do not match the col-span or col-position. Unable to calculate the image-size.");
        return null;
      }

      final ImageElementContext context = new ImageElementContext(colSpan, rowSpan);

      final Node[] columnDefs = columns.getNodeArray();
      int columnCounter = 0;
      for (int i = 0; i < columnDefs.length; i++)
      {
        final Element column = (Element) columnDefs[i];

        if (ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS) == false ||
            ObjectUtilities.equal(column.getType(), "table-column") == false)
        {
          continue;
        }
        if (columnCounter >= columnPos)
        {
          final String colStyle = (String) column.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
          context.setColStyle(columnCounter - columnPos, colStyle);
        }

        columnCounter += 1;

        if (columnCounter >= (columnPos + colSpan))
        {
          break;
        }

      }

      // finally search the styles for the row now.
      final int rowPos = findNodeInSection(table, tableRow,null);
      if (rowPos == -1)
      {
        Log.warn("Table-Cell is not a direct child of the table-row. Unable to calculate the image-size.");
        return null;
      }

      final Node[] rows = table.getNodeArray();
      int rowCounter = 0;
      for (int i = 0; i < rows.length; i++)
      {
        final Element row = (Element) rows[i];

        if (ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS) == false ||
            ObjectUtilities.equal(row.getType(), "table-row") == false)
        {
          continue;
        }
        if (rowCounter >= rowPos)
        {
          final String rowStyle = (String) row.getAttribute(OfficeNamespaces.TABLE_NS, "style-name");
          context.setRowStyle(rowCounter - rowPos, rowStyle);
        }

        rowCounter += 1;
View Full Code Here

      final Node node = nodes[i];
      if (node instanceof Element == false)
      {
        continue;
      }
      final Element child = (Element) node;
      if (ObjectUtilities.equal(child.getNamespace(), namespace) == false ||
          (ObjectUtilities.equal(child.getType(), type) == false
              && (secondType == null || ObjectUtilities.equal(child.getType(), secondType) == false)) )
      {
        continue;
      }

      if (node == tableCell)
View Full Code Here

    while (parent != null)
    {
      final Object node = parent.getNode();
      if (node instanceof Element)
      {
        final Element element = (Element) node;
        if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace()) && "table-cell".equals(element.getType()))
        {
          return parent;
        }
      }
      parent = parent.getParent();
View Full Code Here

            if (!commonStyles.containsStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS))
            {
                final OfficeStyle graphicsDefaultStyle = new OfficeStyle();
                graphicsDefaultStyle.setStyleFamily(OfficeToken.GRAPHIC);
                graphicsDefaultStyle.setStyleName(OfficeToken.GRAPHICS);
                final Element graphicProperties = produceFirstChild(graphicsDefaultStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
                graphicProperties.setAttribute(OfficeNamespaces.TEXT_NS, "anchor-type", OfficeToken.PARAGRAPH);
                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "x", ZERO_CM);
                graphicProperties.setAttribute(OfficeNamespaces.SVG_NS, "y", ZERO_CM);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "wrap", "dynamic");
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "number-wrapped-paragraphs", "no-limit");
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "wrap-contour", OfficeToken.FALSE);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, VERTICAL_POS, "from-top"); // changed for chart

                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "vertical-rel", OfficeToken.PARAGRAPH);
                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, HORIZONTAL_POS, "from-left"); // changed for chart

                graphicProperties.setAttribute(OfficeNamespaces.STYLE_NS, "horizontal-rel", OfficeToken.PARAGRAPH);
                commonStyles.addStyle(graphicsDefaultStyle);
            }

            // Make sure that later generated styles do not overwrite existing styles.
            fillStyleNameGenerator(predefinedStylesCollection);
View Full Code Here

                        final double clipWidth = normalizedImageWidth.getValue() - imageAreaWidthVal.getValue();
                        final double clipHeight = normalizedImageHeight.getValue() - imageAreaHeightVal.getValue();
                        if (clipWidth > 0 && clipHeight > 0)
                        {
                            final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
                            final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
                            final StringBuffer buffer = new StringBuffer();
                            buffer.append("rect(");
                            buffer.append(clipHeight / 2);
                            buffer.append(imageAreaHeightVal.getType().getType());
                            buffer.append(' ');
                            buffer.append(clipWidth / 2);
                            buffer.append(imageAreaWidthVal.getType().getType());
                            buffer.append(' ');
                            buffer.append(clipHeight / 2);
                            buffer.append(imageAreaHeightVal.getType().getType());
                            buffer.append(' ');
                            buffer.append(clipWidth / 2);
                            buffer.append(imageAreaWidthVal.getType().getType());
                            buffer.append(')');
                            graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());

                            styleName = imageStyle.getStyleName();
                            getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
                        }
                        else if (clipWidth > 0)
                        {
                            final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
                            final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
                            final StringBuffer buffer = new StringBuffer();
                            buffer.append("rect(0cm ");
                            buffer.append(clipWidth / 2);
                            buffer.append(imageAreaWidthVal.getType().getType());
                            buffer.append(" 0cm ");
                            buffer.append(clipWidth / 2);
                            buffer.append(imageAreaWidthVal.getType().getType());
                            buffer.append(')');
                            graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());

                            styleName = imageStyle.getStyleName();
                            getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
                            imageAreaHeightVal = normalizedImageHeight;
                        }
                        else if (clipHeight > 0)
                        {
                            final OfficeStyle imageStyle = deriveStyle(OfficeToken.GRAPHIC, OfficeToken.GRAPHICS);
                            final Element graphProperties = produceFirstChild(imageStyle, OfficeNamespaces.STYLE_NS, OfficeToken.GRAPHIC_PROPERTIES);
                            final StringBuffer buffer = new StringBuffer();
                            buffer.append("rect(");
                            buffer.append(clipHeight / 2);
                            buffer.append(imageAreaHeightVal.getType().getType());
                            buffer.append(" 0cm ");
                            buffer.append(clipHeight / 2);
                            buffer.append(imageAreaHeightVal.getType().getType());
                            buffer.append(" 0cm)");
                            graphProperties.setAttribute(OfficeNamespaces.FO_NS, "clip", buffer.toString());

                            styleName = imageStyle.getStyleName();
                            getStylesCollection().getAutomaticStyles().addStyle(imageStyle);
                            imageAreaWidthVal = normalizedImageWidth;
                        }
View Full Code Here

    {
        final OfficeStylesCollection contentStyles = getContentStylesCollection();
        final OfficeStyle style = contentStyles.getStyle(OfficeToken.TABLE_ROW, rowStyle);
        if (style != null)
        {
            final Element element = style.getTableRowProperties();
            if (element != null)
            {
                final String height = (String) element.getAttribute(OfficeNamespaces.STYLE_NS, "row-height");
                if (height != null)
                {
                    return parseLength(height);
                }
            }

            final String styleParent = style.getStyleParent();
            if (styleParent != null)
            {
                return computeRowHeight(styleParent);
            }
        }

        final OfficeStylesCollection globalStyles = getGlobalStylesCollection();
        final OfficeStyle globalStyle = globalStyles.getStyle(OfficeToken.TABLE_ROW, rowStyle);
        if (globalStyle != null)
        {
            final Element element = globalStyle.getTableRowProperties();
            if (element != null)
            {
                final String height = (String) element.getAttribute(OfficeNamespaces.STYLE_NS, "row-height");
                if (height != null)
                {
                    return parseLength(height);
                }
            }
            final String styleParent = globalStyle.getStyleParent();
            if (styleParent != null)
            {
                return computeRowHeight(styleParent);
            }
        }

        final OfficeStylesCollection predefStyles = getPredefinedStylesCollection();
        final OfficeStyle predefStyle = predefStyles.getStyle(OfficeToken.TABLE_ROW, rowStyle);
        if (predefStyle != null)
        {
            final Element element = predefStyle.getTableRowProperties();
            if (element != null)
            {
                final String height = (String) element.getAttribute(OfficeNamespaces.STYLE_NS, "row-height");
                if (height != null)
                {
                    return parseLength(height);
                }
            }
View Full Code Here

TOP

Related Classes of org.jfree.report.structure.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.