Package org.jfree.layouting.layouter.context

Examples of org.jfree.layouting.layouter.context.LayoutContext


      {
        // todo: check for possibly suspended inlines and reactivate them

        final StyleResolver styleResolver = layoutProcess.getStyleResolver();
        final ContextId id = new ContextId(ContextId.SOURCE_DISPLAY_MODEL, -1, 0);
        final LayoutContext paragraphContext =
            styleResolver.createAnonymousContext(id, context);
        fc.addElement(MODEL_INLINE_INSIDE, FLAG_AUTOGENERATED | TYPE_PARAGRAPH, paragraphContext);
        contentGenerator.startedRootInline(paragraphContext);
      }

      // now add the element ..
      final CSSValue displayModel = context.getValue(BoxStyleKeys.DISPLAY_MODEL);
      if (DisplayModel.TABLE.equals(displayModel))
      {
        fc.addElement(MODEL_TABLE, TYPE_INLINE, context);
        contentGenerator.startedTable(context);
      }
      else if (DisplayModel.INLINE_INSIDE.equals(displayModel))
      {
        fc.addElement(MODEL_INLINE_INSIDE, TYPE_INLINE, context);
        contentGenerator.startedInline(context);
      }
      else
      {
        fc.addElement(MODEL_BLOCK_INSIDE, TYPE_BLOCK, context);
        contentGenerator.startedBlock(context);
      }
      return;
    }

    // Todo: need to check for run-in and compact as well..
    // Everything else is considered a block-level element and treated as such..
    final CSSValue displayModel = context.getValue(BoxStyleKeys.DISPLAY_MODEL);
    if (DisplayModel.TABLE.equals(displayModel))
    {
      fc.addElement(MODEL_TABLE, TYPE_TABLE, context);
      contentGenerator.startedTable(context);
    }
    else if (DisplayModel.INLINE_INSIDE.equals(displayModel))
    {
      // A block level element that declares that all its direct childs should
      // be treated as inline-level elements. We create a paragraph box for that
      // one.
      fc.addElement(MODEL_INLINE_INSIDE, TYPE_BLOCK, context);
      contentGenerator.startedBlock(context);

      final StyleResolver styleResolver = layoutProcess.getStyleResolver();
      final ContextId id = new ContextId(ContextId.SOURCE_DISPLAY_MODEL, -1, 0);
      final LayoutContext paragraphContext =
          styleResolver.createAnonymousContext(id, context);
      fc.addElement(MODEL_INLINE_INSIDE,
          FLAG_AUTOGENERATED | TYPE_PARAGRAPH, paragraphContext);
      contentGenerator.startedRootInline(paragraphContext);
    }
View Full Code Here


    // This is some non-table content that has been added to a table.
    // This generally means that someone messed up the layout, we have to
    // generate a default table ...
    final FlowContext fc = (FlowContext) flowContexts.peek();

    final LayoutContext sectionContext =
        styleResolver.createAnonymousContext(id, context);
    fc.addElement(MODEL_TABLE_SECTION, FLAG_AUTOGENERATED | TYPE_TABLE_SECTION, sectionContext);
    contentGenerator.startedTableSection(sectionContext);

    final LayoutContext rowContext =
        styleResolver.createAnonymousContext(id, sectionContext);
    fc.addElement(MODEL_TABLE_ROW, FLAG_AUTOGENERATED | TYPE_TABLE_ROW, rowContext);
    contentGenerator.startedTableRow(rowContext);

    final LayoutContext cellContext =
        styleResolver.createAnonymousContext(id, rowContext);
    fc.addElement(MODEL_BLOCK_INSIDE, FLAG_AUTOGENERATED | TYPE_TABLE_CELL, cellContext);
    contentGenerator.startedTableCell(cellContext);

    addToBlockLevelBox(context);
View Full Code Here

  public void addContent(final ContentToken content)
      throws NormalizationException
  {
    final FlowContext fc = (FlowContext) flowContexts.peek();
    final LayoutContext layoutContext = fc.getCurrentLayoutContext();

    if (suspendCounter > 0)
    {
      contentGenerator.addPassThroughContent(layoutContext, content);
      return;
    }

    final int currentDisplayModel = fc.getActiveDisplayModel();
    if (currentDisplayModel == MODEL_BLOCK_INSIDE)
    {
      // todo: check for suspended inlines and reactivate them if needed.
      if (reactivateSuspendedInlines(fc) == false)
      {
        // generate a inline box ..
        final StyleResolver styleResolver = layoutProcess.getStyleResolver();
        final ContextId id = new ContextId(ContextId.SOURCE_DISPLAY_MODEL, -1, 0);
        final LayoutContext paragraphContext =
            styleResolver.createAnonymousContext(id, layoutContext);
        fc.addElement(MODEL_INLINE_INSIDE, FLAG_AUTOGENERATED | TYPE_PARAGRAPH, paragraphContext);
        contentGenerator.startedRootInline(paragraphContext);
        contentGenerator.addContent(paragraphContext, content);
      }
View Full Code Here

      fc.close();
    }

    while (contexts.isEmpty() == false)
    {
      final LayoutContext lc = (LayoutContext) contexts.pop();
      final int role = roles.pop();
      final int model = models.pop();
      final int cleanRole = role & 0xFFFFFF;
      if (cleanRole == TYPE_INLINE)
      {
View Full Code Here

      {
        callFinish(role);
      }
      else
      {
        final LayoutContext lc = context.getCurrentLayoutContext();
      }
      context.close();
      if (role == TYPE_FLOW)
      {
        context = (FlowContext) flowContexts.peek();
View Full Code Here

   * @param element the elemen that should be resolved.
   */
  public void resolveStyle(final LayoutElement element)
  {
    // this is a three stage process
    final LayoutContext layoutContext = element.getLayoutContext();
    final StyleKey[] keys = getKeys();

//    Log.debug ("Resolving style for " +
//            layoutContext.getTagName() + ":" +
//            layoutContext.getPseudoElement());

    // Stage 0: Initialize with the built-in defaults
    // Stage 1a: Add the parent styles (but only the one marked as inheritable).
    final LayoutElement parent = element.getParent();
    final LayoutStyle initialStyle = getInitialStyle();
    if (layoutContext.copyFrom(initialStyle) == false)
    {
      // ok, manual copy ..
      Log.debug ("Failed to use fast-copy");
      for (int i = 0; i < keys.length; i++)
      {
        final StyleKey key = keys[i];
        layoutContext.setValue(key, initialStyle.getValue(key));
      }
    }

    final LayoutStyle parentStyle;
    if (parent != null)
    {
      parentStyle = parent.getLayoutContext();
      final StyleKey[] inheritedKeys = getInheritedKeys();
      for (int i = 0; i < inheritedKeys.length; i++)
      {
        final StyleKey key = inheritedKeys[i];
        layoutContext.setValue(key, parentStyle.getValue(key));
      }
    }
    else
    {
      parentStyle = initialStyle;
    }

    // Stage 1b: Find all matching stylesheets for the given element
    performSelectionStep(element, layoutContext);

    // Stage 1c: Add the contents of the style attribute, if there is one ..
    // the libLayout style is always added: This is a computed style and the hook
    // for a element neutral user defined tweaking ..

    final AttributeMap attributes = layoutContext.getAttributes();
    final Object libLayoutStyleValue = attributes.getAttribute
            (Namespaces.LIBLAYOUT_NAMESPACE, "style");
    // You cannot override element specific styles with that. So an HTML-style
    // attribute has move value than a LibLayout-style attribute.
    addStyleFromAttribute(element, libLayoutStyleValue);

    if (strictStyleMode)
    {
      performStrictStyleAttr(element);
    }
    else
    {
      performCompleteStyleAttr(element);
    }

    // Stage 2: Compute the 'specified' set of values.
    // Find all explicitly inherited styles and add them from the parent.
    final CSSInheritValue inheritInstance = CSSInheritValue.getInstance();
    for (int i = 0; i < keys.length; i++)
    {
      final StyleKey key = keys[i];
      final Object value = layoutContext.getValue(key);
      if (inheritInstance.equals(value))
      {
        layoutContext.setValue(key, parentStyle.getValue(key));
      }
    }

    // Stage 3:  Compute the computed value set.
    ResolverFactory.getInstance().performResolve
View Full Code Here

   * @param node
   * @param style
   */
  private void performStrictStyleAttr (final LayoutElement node)
  {
    final LayoutContext layoutContext = node.getLayoutContext();
    final String namespace = layoutContext.getNamespace();
    if (namespace == null)
    {
      return;
    }

    final NamespaceCollection namespaces = getNamespaces();
    final NamespaceDefinition ndef = namespaces.getDefinition(namespace);
    if (ndef == null)
    {
      return;
    }

    final AttributeMap attributes = layoutContext.getAttributes();
    final String[] styleAttrs = ndef.getStyleAttribute
            (layoutContext.getTagName());
    for (int i = 0; i < styleAttrs.length; i++)
    {
      final String attr = styleAttrs[i];
      final Object styleValue = attributes.getAttribute(namespace, attr);
      addStyleFromAttribute(node, styleValue);
View Full Code Here

  private void performCompleteStyleAttr (final LayoutElement node)
  {
    final NamespaceCollection namespaces = getNamespaces();
    final String[] namespaceNames = namespaces.getNamespaces();

    final LayoutContext layoutContext = node.getLayoutContext();
    final AttributeMap attributes = layoutContext.getAttributes();

    for (int i = 0; i < namespaceNames.length; i++)
    {
      final String namespace = namespaceNames[i];
      final NamespaceDefinition ndef = namespaces.getDefinition(namespace);
      if (ndef == null)
      {
        continue;
      }

      final String[] styleAttrs = ndef.getStyleAttribute(layoutContext.getTagName());
      for (int x = 0; x < styleAttrs.length; x++)
      {
        final String attr = styleAttrs[x];
        final Object styleValue = attributes.getAttribute(namespace, attr);
        addStyleFromAttribute(node, styleValue);
View Full Code Here

   * @param node
   */
  public void resolveStyle (final LayoutElement node)
  {
    // this is a three stage process
    final LayoutContext layoutContext = node.getLayoutContext();
    final StyleKey[] keys = getKeys();

    // Stage 0: Initialize with the built-in defaults
    // Stage 1a: Add the parent styles (but only the one marked as inheritable).
    final LayoutStyle initialStyle = getInitialStyle();

    // initialize the style ...
    for (int i = 0; i < keys.length; i++)
    {
      final StyleKey key = keys[i];
      layoutContext.setValue(key, initialStyle.getValue(key));
    }

    // Stage 2: Search for all class attributes, and lookup the corresponding
    // style. The sty

View Full Code Here

        final SiblingSelector silbSelect = (SiblingSelector) selector;
        return isSilblingMatch(node, silbSelect);
      }
      case Selector.SAC_PSEUDO_ELEMENT_SELECTOR:
      {
        final LayoutContext layoutContext = node.getLayoutContext();
        return layoutContext.isPseudoElement();
      }
      case Selector.SAC_ELEMENT_NODE_SELECTOR:
      {
        final ElementSelector es = (ElementSelector) selector;
        final LayoutContext layoutContext = node.getLayoutContext();
        final String localName = es.getLocalName();
        if (localName != null)
        {
          if (localName.equals(layoutContext.getTagName()) == false)
          {
            return false;
          }
        }
        final String namespaceURI = es.getNamespaceURI();
        if (namespaceURI != null)
        {
          if (namespaceURI.equals(layoutContext.getNamespace()) == false)
          {
            return false;
          }
        }
        return true;
View Full Code Here

TOP

Related Classes of org.jfree.layouting.layouter.context.LayoutContext

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.