Package com.agiletec.plugins.jpimagemap.aps.system.services.content.model.attribute.util

Examples of com.agiletec.plugins.jpimagemap.aps.system.services.content.model.attribute.util.LinkedArea


    if (this.getImage() != null) {
      this.getImage().setRenderingLang(langCode);
      if (_areas.size() > 0) {
        Iterator<LinkedArea> iteratorAreas = _areas.iterator();
        while (iteratorAreas.hasNext()) {
          LinkedArea linkedArea = (LinkedArea) iteratorAreas.next();
          linkedArea.getLink().setRenderingLang(langCode);
        }
      }
    }
  }
View Full Code Here


 
  @Override
  public void setComplexAttributeConfig(Element attributeElement, Map attrTypes) throws ApsSystemException {
    _image = (ImageAttribute) ((ImageAttribute) attrTypes.get("Image")).getAttributePrototype();
    _image.setAttributeConfig(attributeElement);
    _prototype = new LinkedArea();
    _prototype.setLink((LinkAttribute)((LinkAttribute) attrTypes.get("Link")).getAttributePrototype());
    _prototype.getLink().setAttributeConfig(attributeElement);
  }
View Full Code Here

      if (_areas.size() > 0) {
        Element areas = new Element("areas");
        Iterator iteratorAreas = _areas.iterator();
        while (iteratorAreas.hasNext()) {
          Element area = new Element("area");
          LinkedArea linkedArea = (LinkedArea) iteratorAreas.next();
          area.setAttribute("shape", linkedArea.getShape());
          area.setAttribute("coords", linkedArea.getCoords());
          area.addContent(linkedArea.getLink().getJDOMElement());
          areas.addContent(area);
        }
        attributeElement.addContent(areas);
      }
    }
View Full Code Here

 
  public LinkedArea getArea(int index){
    return _areas.get(index);
  }
  public LinkedArea addArea() {
    LinkedArea newArea = (LinkedArea) this._prototype.clone();
    newArea.setShape("rect");
    //TODO per ora solo rect come forma
    newArea.setCoords("0,0,0,0");
    newArea.getLink().setDefaultLangCode(this.getDefaultLangCode());
    this._areas.add(newArea);
    return newArea;
  }
View Full Code Here

  protected Object getJAXBValue(String langCode) {
    JAXBImageMapValue imageMapValue = new JAXBImageMapValue();
    JAXBResourceValue jaxbImageValue = (JAXBResourceValue) this.getImage().getJAXBAttribute(langCode).getValue();
    imageMapValue.setImage(jaxbImageValue);
    for (int i = 0; i < this.getAreas().size(); i++) {
      LinkedArea area = this.getAreas().get(i);
      JAXBAreaValue areaValue = new JAXBAreaValue();
      JAXBLinkValue areaLinkValue = (JAXBLinkValue) area.getLink().getJAXBAttribute(langCode).getValue();
      areaValue.setLink(areaLinkValue);
      areaValue.setShape(area.getShape());
      areaValue.setCoords(area.getCoords());
      imageMapValue.addArea(areaValue);
    }
    return imageMapValue;
  }
View Full Code Here

      if (null != value.getAreas()) {
        for (int i = 0; i < value.getAreas().size(); i++) {
          JAXBAreaValue areaValue = value.getAreas().get(i);
          JAXBLinkValue areaLinkValue = areaValue.getLink();
          if (null == areaValue || null == areaLinkValue) continue;
          LinkedArea linkedArea = (LinkedArea) this.getPrototype().clone();
          linkedArea.setShape(areaValue.getShape());
          linkedArea.setCoords(areaValue.getCoords());
          linkedArea.getLink().setSymbolicLink(areaLinkValue.getSymbolikLink());
          Object textValue = areaLinkValue.getText();
          if (null == textValue) return;
          linkedArea.getLink().getTextMap().put(this.getDefaultLangCode(), textValue.toString());
        }
      }
        } catch (Exception e) {
            ApsSystemUtils.logThrowable(e, this, "valueFrom", "Error extracting linked area from jaxbAttribute");
        }
View Full Code Here

  @Override
  public String saveArea() {
    Logger log = ApsSystemUtils.getLogger();
    try {
      ImageMapAttribute currentAttribute = this.getAttribute();
      LinkedArea area = currentAttribute.getArea(this.getElementIndex());
      area.setCoords(this.concatCoords());
      log.trace("SAVED Area " + this.getElementIndex() + " for ImageMap " + currentAttribute.getName());
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "saveArea");
      return FAILURE;
    }
View Full Code Here

        List<AttributeFieldError> errors = super.validate(tracer);
        try {
            if (null == this.getResource()) return errors;
      List<LinkedArea> areas = this.getAreas();
      for (int i = 0; i < areas.size(); i++) {
        LinkedArea area = (LinkedArea) areas.get(i);
        AttributeTracer areaTracer = (AttributeTracer) tracer.clone();
        areaTracer.setMonoListElement(true);
        areaTracer.setListIndex(i);
        LinkAttribute linkAttribute = area.getLink();
        if (null != linkAttribute) {
          errors.addAll(linkAttribute.validate(areaTracer));
        }
        String coords = area.getCoords();
        boolean isShapeValued = (area.getShape() != null && area.getShape().trim().length() > 0 );
        boolean isCoordsValued = (coords!= null && coords.trim().length() > 0 && this.isValidNumber(coords));
        if (!isShapeValued || !isCoordsValued) {
          errors.add(new AttributeFieldError(this, INVALID_LINKED_AREA_ERROR, areaTracer));
          /*
          String formFieldName = tracer.getFormFieldName(imageMapAttribute);
View Full Code Here

    Integer[] coordsArray = area.getArrayCoords();
    if (null == coordsArray) return;
    Rectangle areaRect =
      new Rectangle(coordsArray[0].intValue(), coordsArray[1].intValue(), coordsArray[2].intValue() - coordsArray[0].intValue() , coordsArray[3].intValue() - coordsArray[1].intValue());
    for (int i=index-1; i>=0 ; i--){
      LinkedArea currentArea = this.getArea(i);
      Integer[] currentCoordsArray = currentArea.getArrayCoords();
      Rectangle currentAreaRect = new Rectangle(currentCoordsArray[0].intValue(),currentCoordsArray[1].intValue(),
          currentCoordsArray[2].intValue() - currentCoordsArray[0].intValue() , currentCoordsArray[3].intValue() - currentCoordsArray[1].intValue());
      boolean intersect = areaRect.intersects(currentAreaRect);
      if (intersect) {
        errors.add(new AttributeFieldError(this, INVALID_LINKED_AREA_ERROR, tracer));
View Full Code Here

    AttributeTracer imageTracer = (AttributeTracer) tracer.clone();
    ResourceAttributeManager imageManager = (ResourceAttributeManager) this.getManager(imageAttr);
    imageManager.updateAttribute(imageAttr, imageTracer, request);
    List<LinkedArea> areas = imageMapAttribute.getAreas();
    for (int i = 0; i < areas.size(); i++) {
      LinkedArea area = (LinkedArea) areas.get(i);
      AttributeTracer areaTracer = (AttributeTracer) tracer.clone();
      areaTracer.setMonoListElement(true);
      areaTracer.setListIndex(i);
      LinkAttribute link = area.getLink();
      LinkAttributeManager linkManager = (LinkAttributeManager) this.getManager(link);
      String coords = request.getParameter(imageMapAttribute.getName() + "_coords_" + areaTracer.getListIndex());
      linkManager.updateAttribute(link, areaTracer, request);
      area.setCoords(coords);
    }
  }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpimagemap.aps.system.services.content.model.attribute.util.LinkedArea

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.