Ejemplo n.º 1
0
  private void validate(String elementName) throws XmlPullParserException {
    XmlUtils.checkMandatoryAttribute(elementName, E, this.element);
    XmlUtils.checkMandatoryAttribute(elementName, K, this.keys);
    XmlUtils.checkMandatoryAttribute(elementName, V, this.values);

    if (this.zoomMin > this.zoomMax) {
      throw new XmlPullParserException(
          '\'' + ZOOM_MIN + "' > '" + ZOOM_MAX + "': " + this.zoomMin + ' ' + this.zoomMax);
    }
  }
Ejemplo n.º 2
0
  private void extractValues(String elementName, XmlPullParser pullParser)
      throws IOException, XmlPullParserException {

    this.repeatGap = REPEAT_GAP_DEFAULT * displayModel.getScaleFactor();
    this.repeatStart = REPEAT_START_DEFAULT * displayModel.getScaleFactor();

    for (int i = 0; i < pullParser.getAttributeCount(); ++i) {
      String name = pullParser.getAttributeName(i);
      String value = pullParser.getAttributeValue(i);

      if (SRC.equals(name)) {
        this.src = value;
      } else if (DISPLAY.equals(name)) {
        this.display = Display.fromString(value);
      } else if (DY.equals(name)) {
        this.dy = Float.parseFloat(value) * displayModel.getScaleFactor();
      } else if (ALIGN_CENTER.equals(name)) {
        this.alignCenter = Boolean.parseBoolean(value);
      } else if (CAT.equals(name)) {
        this.category = value;
      } else if (PRIORITY.equals(name)) {
        this.priority = Integer.parseInt(value);
      } else if (REPEAT.equals(name)) {
        this.repeat = Boolean.parseBoolean(value);
      } else if (REPEAT_GAP.equals(name)) {
        this.repeatGap = Float.parseFloat(value) * displayModel.getScaleFactor();
      } else if (REPEAT_START.equals(name)) {
        this.repeatStart = Float.parseFloat(value) * displayModel.getScaleFactor();
      } else if (ROTATE.equals(name)) {
        this.rotate = Boolean.parseBoolean(value);
      } else if (SYMBOL_HEIGHT.equals(name)) {
        this.height = XmlUtils.parseNonNegativeInteger(name, value) * displayModel.getScaleFactor();
      } else if (SYMBOL_PERCENT.equals(name)) {
        this.percent = XmlUtils.parseNonNegativeInteger(name, value);
      } else if (SYMBOL_SCALING.equals(name)) {
        this.scaling = fromValue(value);
      } else if (SYMBOL_WIDTH.equals(name)) {
        this.width = XmlUtils.parseNonNegativeInteger(name, value) * displayModel.getScaleFactor();
      } else {
        throw XmlUtils.createXmlPullParserException(elementName, name, value, i);
      }
    }
  }
Ejemplo n.º 3
0
  protected Bitmap createBitmap(String relativePathPrefix, String src) throws IOException {
    if (null == src || src.isEmpty()) {
      return null;
    }

    if (scaling == RenderInstruction.ResourceScaling.TILE) {
      width = displayModel.getTilingSize();
      height = displayModel.getTilingSize();
    }

    return XmlUtils.createBitmap(
        graphicFactory, displayModel, relativePathPrefix, src, (int) width, (int) height, percent);
  }
Ejemplo n.º 4
0
  private void extractValues(String elementName, XmlPullParser pullParser)
      throws XmlPullParserException {
    for (int i = 0; i < pullParser.getAttributeCount(); ++i) {
      String name = pullParser.getAttributeName(i);
      String value = pullParser.getAttributeValue(i);

      if (E.equals(name)) {
        this.element = Element.fromString(value);
      } else if (K.equals(name)) {
        this.keys = value;
      } else if (V.equals(name)) {
        this.values = value;
      } else if (CAT.equals(name)) {
        this.cat = value;
      } else if (CLOSED.equals(name)) {
        this.closed = Closed.fromString(value);
      } else if (ZOOM_MIN.equals(name)) {
        this.zoomMin = XmlUtils.parseNonNegativeByte(name, value);
      } else if (ZOOM_MAX.equals(name)) {
        this.zoomMax = XmlUtils.parseNonNegativeByte(name, value);
      } else {
        throw XmlUtils.createXmlPullParserException(elementName, name, value, i);
      }
    }

    validate(elementName);

    this.keyList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(this.keys)));
    this.valueList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(this.values)));

    this.elementMatcher = getElementMatcher(this.element);
    this.closedMatcher = getClosedMatcher(this.closed);

    this.elementMatcher = RuleOptimizer.optimize(this.elementMatcher, this.ruleStack);
    this.closedMatcher = RuleOptimizer.optimize(this.closedMatcher, this.ruleStack);
  }