Package org.pentaho.reporting.engine.classic.core.style

Examples of org.pentaho.reporting.engine.classic.core.style.StyleSheet


    box.clearLayout();

    if (box.isComplexParagraph())
    {
      final RenderBox lineBoxContainer = box.getLineboxContainer();
      final StyleSheet layoutContext = box.getStyleSheet();

      RenderNode paragraphContainer = lineBoxContainer.getFirstChild();
      while (paragraphContainer != null)
      {
        if (paragraphContainer.getNodeType() != LayoutNodeTypes.TYPE_BOX_LINEBOX)
        {
          throw new IllegalStateException("Expected ParagraphPoolBox elements.");
        }

        final ParagraphPoolBox paragraph = (ParagraphPoolBox) paragraphContainer;
        addGeneratedComplexTextLines(box, paragraph, layoutContext);

        paragraphContainer = paragraphContainer.getNext();
      }
    }
    else
    {
      final ParagraphPoolBox lineBoxContainer = (ParagraphPoolBox) box.getEffectiveLineboxContainer();
      final StyleSheet layoutContext = box.getStyleSheet();

      addGeneratedComplexTextLines(box, lineBoxContainer, layoutContext);
    }
  }
View Full Code Here


    if (value instanceof Image)
    {
      try
      {
        final ImageContainer imageContainer = new DefaultImageReference((Image) value);
        final StyleSheet rawSource = textExtractor.getRawSource().getStyleSheet();
        final StrictBounds contentBounds =
            new StrictBounds(content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight());
        createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      }
      catch (IOException ioe)
      {
        // Should not happen.
        ExcelPrinter.logger.warn("Failed to process AWT-Image in Excel-Export", ioe);
      }
      return true;
    }
    else if (value instanceof ImageContainer)
    {
      final ImageContainer imageContainer = (ImageContainer) value;
      // todo: this is wrong ..
      final StyleSheet rawSource = textExtractor.getRawSource().getStyleSheet();
      final StrictBounds contentBounds =
          new StrictBounds(content.getX(), content.getY() + contentOffset, content.getWidth(), content.getHeight());
      createImageCell(rawSource, imageContainer, sheetLayout, rectangle, contentBounds);
      return true;
    }
    else if (value instanceof DrawableWrapper)
    {
      final DrawableWrapper drawable = (DrawableWrapper) value;
      final RenderNode rawSource = textExtractor.getRawSource();
      final StrictBounds contentBounds = new StrictBounds
          (rawSource.getX(), rawSource.getY() + contentOffset, rawSource.getWidth(), rawSource.getHeight());
      final ImageContainer imageFromDrawable =
          RenderUtility.createImageFromDrawable(drawable, contentBounds, content, getMetaData());
      createImageCell(rawSource.getStyleSheet(), imageFromDrawable, sheetLayout, rectangle, contentBounds);
      return true;
    }
    else if (value instanceof Shape)
    {
      // We *could* do this as well ... but for now we dont.
View Full Code Here

    g2.draw(boxArea);
  }

  protected void processLinksAndAnchors(final RenderNode box)
  {
    final StyleSheet styleSheet = box.getStyleSheet();
    final String target = (String) styleSheet.getStyleProperty(ElementStyleKeys.HREF_TARGET);
    final String title = (String) styleSheet.getStyleProperty(ElementStyleKeys.HREF_TITLE);
    if (target != null || title != null)
    {
      final String window = (String) styleSheet.getStyleProperty(ElementStyleKeys.HREF_WINDOW);
      drawHyperlink(box, target, window, title);
    }

    final String anchor = (String) styleSheet.getStyleProperty(ElementStyleKeys.ANCHOR_NAME);
    if (anchor != null)
    {
      drawAnchor(box);
    }

    final String bookmark = (String) styleSheet.getStyleProperty(BandStyleKeys.BOOKMARK);
    if (bookmark != null)
    {
      drawBookmark(box, bookmark);
    }
  }
View Full Code Here

    this.textSpec = textSpec;
  }

  private FontDecorationSpec computeUnderline(final RenderBox box, FontDecorationSpec oldSpec)
  {
    final StyleSheet styleSheet = box.getStyleSheet();
    if (styleSheet.getBooleanStyleProperty(TextStyleKeys.UNDERLINED) == false)
    {
      return null;
    }
    if (oldSpec == null)
    {
View Full Code Here

    return oldSpec;
  }

  private FontDecorationSpec computeStrikeThrough(final RenderBox box, FontDecorationSpec oldSpec)
  {
    final StyleSheet styleSheet = box.getStyleSheet();
    if (styleSheet.getBooleanStyleProperty(TextStyleKeys.STRIKETHROUGH) == false)
    {
      return null;
    }
    if (oldSpec == null)
    {
View Full Code Here

              // The text node that is printed will overlap with the ellipse we need to print.
              final Graphics2D g2;
              if (getTextSpec() == null)
              {
                g2 = (Graphics2D) getGraphics().create();
                final StyleSheet layoutContext = text.getStyleSheet();
                configureGraphics(layoutContext, g2);
                g2.setStroke(LogicalPageDrawable.DEFAULT_STROKE);

                if (RenderUtility.isFontSmooth(layoutContext, metaData))
                {
                  g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                }
                else
                {
                  g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
                }
              }
              else
              {
                g2 = getTextSpec().getGraphics();
              }

              drawComplexText(text, g2);
            }
          }

          ellipseDrawn = true;

          final RenderBox parent = node.getParent();
          if (parent != null)
          {
            final RenderBox textEllipseBox = parent.getTextEllipseBox();
            if (textEllipseBox != null)
            {
              processBoxChilds(textEllipseBox);
            }
          }
          return;
        }
      }
    }

    if (type == LayoutNodeTypes.TYPE_NODE_TEXT)
    {
      final RenderableText text = (RenderableText) node;
      if (underline != null)
      {
        final ExtendedBaselineInfo baselineInfo = text.getBaselineInfo();
        final long underlinePos = text.getY() + baselineInfo.getUnderlinePosition();
        underline.updateVerticalPosition(StrictGeomUtility.toExternalValue(underlinePos));
        underline.updateStart(StrictGeomUtility.toExternalValue(text.getX()));
        underline.updateEnd(StrictGeomUtility.toExternalValue(text.getX() + text.getWidth()));
      }

      if (strikeThrough != null)
      {
        final ExtendedBaselineInfo baselineInfo = text.getBaselineInfo();
        final long strikethroughPos = text.getY() + baselineInfo.getStrikethroughPosition();
        strikeThrough.updateVerticalPosition(StrictGeomUtility.toExternalValue(strikethroughPos));
        strikeThrough.updateStart(StrictGeomUtility.toExternalValue(text.getX()));
        strikeThrough.updateEnd(StrictGeomUtility.toExternalValue(text.getX() + text.getWidth()));
      }

      if (isTextLineOverflow())
      {
        final long ellipseSize = extractEllipseSize(node);
        final long x1 = text.getX();
        final long x2 = x1 + text.getWidth();
        final long effectiveAreaX2 = (contentAreaX2 - ellipseSize);
        if (x2 <= effectiveAreaX2)
        {
          // the text will be fully visible.
          drawText(text);
        }
        else
        {
          if (x1 >= contentAreaX2)
          {
            // Skip, the node will not be visible.
          }
          else
          {
            // The text node that is printed will overlap with the ellipse we need to print.
            drawText(text, effectiveAreaX2);
          }

          final RenderBox parent = node.getParent();
          if (parent != null)
          {
            final RenderBox textEllipseBox = parent.getTextEllipseBox();
            if (textEllipseBox != null)
            {
              processBoxChilds(textEllipseBox);
            }
          }

          ellipseDrawn = true;
        }
      }
      else
      {
        drawText(text);
      }
    }
    else if (type == LayoutNodeTypes.TYPE_NODE_COMPLEX_TEXT)
    {
      final RenderableComplexText text = (RenderableComplexText) node;
      final long x1 = text.getX();

      if (x1 >= contentAreaX2)
      {
        // Skip, the node will not be visible.
      }
      else
      {
        // The text node that is printed will overlap with the ellipse we need to print.
        final Graphics2D g2;
        if (getTextSpec() == null)
        {
          g2 = (Graphics2D) getGraphics().create();
          final StyleSheet layoutContext = text.getStyleSheet();
          configureGraphics(layoutContext, g2);
          g2.setStroke(LogicalPageDrawable.DEFAULT_STROKE);

          if (RenderUtility.isFontSmooth(layoutContext, metaData))
          {
View Full Code Here

   * @param content
   * @param image
   */
  protected boolean drawImage(final RenderableReplacedContentBox content, Image image)
  {
    final StyleSheet layoutContext = content.getStyleSheet();
    final boolean shouldScale = layoutContext.getBooleanStyleProperty(ElementStyleKeys.SCALE);

    final int x = (int) StrictGeomUtility.toExternalValue(content.getX());
    final int y = (int) StrictGeomUtility.toExternalValue(content.getY());
    final int width = (int) StrictGeomUtility.toExternalValue(content.getWidth());
    final int height = (int) StrictGeomUtility.toExternalValue(content.getHeight());

    if (width == 0 || height == 0)
    {
      LogicalPageDrawable.logger.debug("Error: Image area is empty: " + content);
      return false;
    }

    WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    final int imageWidth = image.getWidth(obs);
    final int imageHeight = image.getHeight(obs);
    if (imageWidth < 1 || imageHeight < 1)
    {
      return false;
    }

    final Rectangle2D.Double drawAreaBounds = new Rectangle2D.Double(x, y, width, height);
    final AffineTransform scaleTransform;

    final Graphics2D g2;
    if (shouldScale == false)
    {
      double deviceScaleFactor = 1;
      final double devResolution = metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
      if (metaData.isFeatureSupported(OutputProcessorFeature.IMAGE_RESOLUTION_MAPPING))
      {
        if (devResolution != 72.0 && devResolution > 0)
        {
          // Need to scale the device to its native resolution before attempting to draw the image..
          deviceScaleFactor = (72.0 / devResolution);
        }
      }

      final int clipWidth = Math.min(width, (int) Math.ceil(deviceScaleFactor * imageWidth));
      final int clipHeight = Math.min(height, (int) Math.ceil(deviceScaleFactor * imageHeight));
      final ElementAlignment horizontalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.ALIGNMENT);
      final ElementAlignment verticalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.VALIGNMENT);
      final int alignmentX = (int) RenderUtility.computeHorizontalAlignment(horizontalAlignment, width, clipWidth);
      final int alignmentY = (int) RenderUtility.computeVerticalAlignment(verticalAlignment, height, clipHeight);

      g2 = (Graphics2D) getGraphics().create();
      g2.clip(drawAreaBounds);
      g2.translate(x, y);
      g2.translate(alignmentX, alignmentY);
      g2.clip(new Rectangle2D.Float(0, 0, clipWidth, clipHeight));
      g2.scale(deviceScaleFactor, deviceScaleFactor);

      scaleTransform = null;
    }
    else
    {
      g2 = (Graphics2D) getGraphics().create();
      g2.clip(drawAreaBounds);
      g2.translate(x, y);
      g2.clip(new Rectangle2D.Float(0, 0, width, height));

      final double scaleX;
      final double scaleY;

      final boolean keepAspectRatio = layoutContext.getBooleanStyleProperty(ElementStyleKeys.KEEP_ASPECT_RATIO);
      if (keepAspectRatio)
      {
        final double scaleFactor = Math.min(width / (double) imageWidth, height / (double) imageHeight);
        scaleX = scaleFactor;
        scaleY = scaleFactor;
      }
      else
      {
        scaleX = width / (double) imageWidth;
        scaleY = height / (double) imageHeight;
      }

      final int clipWidth = (int) (scaleX * imageWidth);
      final int clipHeight = (int) (scaleY * imageHeight);

      final ElementAlignment horizontalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.ALIGNMENT);
      final ElementAlignment verticalAlignment =
          (ElementAlignment) layoutContext.getStyleProperty(ElementStyleKeys.VALIGNMENT);
      final int alignmentX = (int) RenderUtility.computeHorizontalAlignment(horizontalAlignment, width, clipWidth);
      final int alignmentY = (int) RenderUtility.computeVerticalAlignment(verticalAlignment, height, clipHeight);

      g2.translate(alignmentX, alignmentY);

View Full Code Here

    }

    final Graphics2D clone = (Graphics2D) g2.create();


    final StyleSheet styleSheet = content.getStyleSheet();
    final Object attribute = styleSheet.getStyleProperty(ElementStyleKeys.ANTI_ALIASING);
    if (attribute != null)
    {
      if (Boolean.TRUE.equals(attribute))
      {
        clone.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      }
      else if (Boolean.FALSE.equals(attribute))
      {
        clone.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
      }

    }
    if (RenderUtility.isFontSmooth(styleSheet, metaData))
    {
      clone.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
    else
    {
      clone.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
    }

    if (strictClipping == false)
    {
      final double extraPadding;
      final Object o = styleSheet.getStyleProperty(ElementStyleKeys.STROKE);
      if (o instanceof BasicStroke)
      {
        final BasicStroke stroke = (BasicStroke) o;
        extraPadding = stroke.getLineWidth() / 2.0;
      }
View Full Code Here

    final Graphics2D g2;
    if (getTextSpec() == null)
    {
      g2 = (Graphics2D) getGraphics().create();
      final StyleSheet layoutContext = renderableText.getStyleSheet();
      configureGraphics(layoutContext, g2);
      g2.setStroke(LogicalPageDrawable.DEFAULT_STROKE);

      if (RenderUtility.isFontSmooth(layoutContext, metaData))
      {
View Full Code Here

    RenderNode[] elementsByElementType = MatchFactory.findElementsByElementType(logicalPageBox, LabelType.INSTANCE);
    for (int i = 0; i < elementsByElementType.length; i++)
    {
      RenderNode renderNode = elementsByElementType[i];
      StyleSheet styleSheet = renderNode.getNodeLayoutProperties().getStyleSheet();
      Object styleProperty = styleSheet.getStyleProperty(TextStyleKeys.FONT);
      Assert.assertEquals("Arial", styleProperty);
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.style.StyleSheet

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.