Package org.jfree.layouting.input.style.values

Examples of org.jfree.layouting.input.style.values.CSSNumericValue


                    len.add((CSSNumericValue) rowHeights.get(i));
                    // val += ((CSSNumericValue)rowHeights.get(i)).getValue();
                }

                rowHeights.clear();
                final CSSNumericValue currentRowHeight = len.getResult();
                rowHeights.add(currentRowHeight);
                attrs.setAttribute(OfficeNamespaces.DRAWING_NS, "z-index", String.valueOf(shapes.size()));
                final String y = (String) attrs.getAttribute(OfficeNamespaces.SVG_NS, "y");
                if ( y != null )
                {
                    len.add(parseLength(y));
                    final CSSNumericValue currentY = len.getResult();
                    attrs.setAttribute(OfficeNamespaces.SVG_NS, "y", currentY.getValue() + currentY.getType().getType());
                }
                shapes.add(attrs);
            }
            return;
        }
View Full Code Here


        final OfficeMasterPage masterPage;
        if ( !masterPageFactory.containsMasterPage("Standard", null, null) )
        {
            masterPage = masterPageFactory.createMasterPage("Standard", null, null);

            final CSSNumericValue zeroLength = CSSNumericValue.createValue(CSSNumericType.CM, 0);
            final String pageLayoutTemplate = masterPage.getPageLayout();
            if ( pageLayoutTemplate == null )
            {
                // there is no pagelayout. Create one ..
                final String derivedLayout = masterPageFactory.createPageStyle(getGlobalStylesCollection().getAutomaticStyles(), zeroLength, zeroLength);
View Full Code Here

  {
    final ConverterAttributeSet attr = new ConverterAttributeSet();

    if(paragraphConstant == StyleConstants.FirstLineIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(TextStyleKeys.TEXT_INDENT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.RightIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_RIGHT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.LeftIndent)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_LEFT.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.LineSpacing)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.EM, Double.parseDouble(value.toString()));
      attr.addAttribute(LineStyleKeys.LINE_HEIGHT, cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.SpaceAbove)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_TOP.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.SpaceBelow)
    {
      final CSSNumericValue cssNumericValue = CSSNumericValue.createValue(CSSNumericType.PT, Double.parseDouble(value.toString()));
      attr.addAttribute(BoxStyleKeys.MARGIN_BOTTOM.getName(), cssNumericValue);
    }
    else if(paragraphConstant == StyleConstants.Alignment)
    {
      Object val = null;
View Full Code Here

    if (rawValue instanceof CSSNumericValue == false)
    {
      return 0;
    }

    final CSSNumericValue value = (CSSNumericValue) rawValue;
    if (CSSNumericType.PT.equals(value.getType()))
    {
      return value.getValue();
    }
    if (CSSNumericType.PC.equals(value.getType()))
    {
      return (value.getValue() / 12.0d);
    }
    if (CSSNumericType.INCH.equals(value.getType()))
    {
      return (value.getValue() / 72.0d);
    }
    if (CSSNumericType.CM.equals(value.getType()))
    {
      return ((value.getValue() * 100 * 72.0d) / 254.0d);
    }
    if (CSSNumericType.MM.equals(value.getType()))
    {
      return ((value.getValue() * 10 * 72.0d) / 254.0d);
    }

    if (CSSNumericType.PX.equals(value.getType()))
    {
      final int pixelPerInch;
      if (metaData != null)
      {
        pixelPerInch = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
      }
      else
      {
        pixelPerInch = 96;
      }
      if (pixelPerInch <= 0)
      {
        // we assume 72 pixel per inch ...
        return value.getValue();
      }
      return value.getValue() * 72d / pixelPerInch;
    }

    if (metaData == null)
    {
      return 0;
    }

    if (context != null)
    {
      if (CSSNumericType.EM.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final double fontSize = fspec.getFontSize();
        return (fontSize * value.getValue());
      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final FontMetrics fontMetrics = metaData.getFontMetrics(fspec);
        if (fontMetrics == null)
        {
          final long fontSize = (long) (fspec.getFontSize() * DEFAULT_X_HEIGHT_FACTOR);
          return StrictGeomUtility.toExternalValue((long) (value.getValue() * fontSize));
        }
        else
        {
          return StrictGeomUtility.toExternalValue((long) (value.getValue() * fontMetrics.getXHeight()));
        }
      }
    }
    return 0;
  }
View Full Code Here

    if (rawValue instanceof CSSNumericValue == false)
    {
      return 0;
    }

    final CSSNumericValue value = (CSSNumericValue) rawValue;
    final long internal = StrictGeomUtility.toInternalValue(value.getValue());
    if (CSSNumericType.PT.equals(value.getType()))
    {
      return internal;
    }
    if (CSSNumericType.PC.equals(value.getType()))
    {
      return (internal / 12);
    }
    if (CSSNumericType.INCH.equals(value.getType()))
    {
      return (internal / 72);
    }
    if (CSSNumericType.CM.equals(value.getType()))
    {
      return (internal * 100 * 72 / 254);
    }
    if (CSSNumericType.MM.equals(value.getType()))
    {
      return (internal * 10 * 72 / 254);
    }

    if (CSSNumericType.PX.equals(value.getType()))
    {
      final int pixelPerInch;
      if (metaData != null)
      {
        pixelPerInch = (int) metaData.getNumericFeatureValue(OutputProcessorFeature.DEVICE_RESOLUTION);
      }
      else
      {
        pixelPerInch = 96;
      }
      if (pixelPerInch <= 0)
      {
        // we assume 72 pixel per inch ...
        return internal;
      }
      return internal * 72 / pixelPerInch;
    }

    if (metaData == null)
    {
      return 0;
    }

    if (context != null)
    {
      if (CSSNumericType.EM.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final double fontSize = fspec.getFontSize();
        return (long) (fontSize * internal);
      }
      if (CSSNumericType.EX.equals(value.getType()))
      {
        final FontSpecification fspec =
            context.getFontSpecification();
        final FontMetrics fontMetrics = metaData.getFontMetrics(fspec);
        if (fontMetrics == null)
View Full Code Here

    if (rawValue instanceof CSSStringValue)
    {
      final CSSStringValue strVal = (CSSStringValue) rawValue;
      try
      {
        final CSSNumericValue nval = FunctionUtilities.parseNumberValue(strVal.getValue());
        number = nval.getValue();
      }
      catch(FunctionEvaluationException fee)
      {
        return new StaticTextToken (strVal.getValue());
      }
    }
    else if (rawValue instanceof CSSNumericValue)
    {
      final CSSNumericValue nval = (CSSNumericValue) rawValue;
      number = nval.getValue();
    }
    else
    {
      // Raw-Values should not have been created for number values
      throw new FunctionEvaluationException("Not a numeric value.");
View Full Code Here

  {
  }

  protected int validateHueParameter (final CSSValue value) throws FunctionEvaluationException
  {
    final CSSNumericValue nval;
    if (value instanceof CSSStringValue)
    {
      // I shouldn't do this, but ..
      final CSSStringValue strVal = (CSSStringValue) value;
      nval = FunctionUtilities.parseNumberValue(strVal.getValue());
    }
    else if (value instanceof CSSNumericValue == false)
    {
      throw new FunctionEvaluationException("Expected a number");
    }
    else
    {
      nval = (CSSNumericValue) value;
    }
    if (nval.getType().equals(CSSNumericType.NUMBER))
    {
      return (int) (nval.getValue() % 360);
    }
    throw new FunctionEvaluationException("Expected a number, not a length");
  }
View Full Code Here

    throw new FunctionEvaluationException("Expected a number, not a length");
  }

  protected float validateOtherParameter (final CSSValue value) throws FunctionEvaluationException
  {
    final CSSNumericValue nval;
    if (value instanceof CSSStringValue)
    {
      // I shouldn't do this, but ..
      final CSSStringValue strVal = (CSSStringValue) value;
      nval = FunctionUtilities.parseNumberValue(strVal.getValue());
    }
    else if (value instanceof CSSNumericValue == false)
    {
      throw new FunctionEvaluationException("Expected a number");
    }
    else
    {
      nval = (CSSNumericValue) value;
    }
    if (nval.getType().equals(CSSNumericType.PERCENTAGE))
    {
      return (float) (nval.getValue() % 100);
    }
    throw new FunctionEvaluationException("Expected a number, not a length");
  }
View Full Code Here

  {
  }

  protected int validateParameter (final CSSValue value) throws FunctionEvaluationException
  {
    final CSSNumericValue nval;
    if (value instanceof CSSStringValue)
    {
      // I shouldn't do this, but ..
      final CSSStringValue strVal = (CSSStringValue) value;
      nval = FunctionUtilities.parseNumberValue(strVal.getValue());
    }
    else if (value instanceof CSSNumericValue == false)
    {
      throw new FunctionEvaluationException("Expected a number");
    }
    else
    {
      nval = (CSSNumericValue) value;
    }
    if (nval.getType().equals(CSSNumericType.NUMBER))
    {
      return (int) (nval.getValue() % 256);
    }
    if (nval.getType().equals(CSSNumericType.PERCENTAGE))
    {
      return (int) (nval.getValue() * 256.0 / 100.0);
    }
    throw new FunctionEvaluationException("Expected a number, not a length");
  }
View Full Code Here

    if (value instanceof CSSNumericValue == false)
    {
      return null;
    }

    final CSSNumericValue nval = (CSSNumericValue) value;
    if (isNumericType(CSSNumericType.PERCENTAGE, nval))
    {
      return null;
    }
View Full Code Here

TOP

Related Classes of org.jfree.layouting.input.style.values.CSSNumericValue

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.