Exemplo n.º 1
0
  /**
   * Заполнить держатель атрибутов
   *
   * @param gl Глиф, с которого получаем атрибуты
   * @return Получить хранитель атрибутов
   */
  public static AttributeHolder fillAttributeHolder(Glyph gl) {
    AttributeHolder attributeHolder = new AttributeHolder();
    Integer uid = gl.getId();
    attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_UID, uid);
    Integer type = gl.getType();
    attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_TYPE, type);
    Color color = gl.getColor();
    attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_COLOR, color);
    String text = gl.getText();
    if (text != null) {
      attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_TEXT, text);
    }
    int status = gl.getStatus();
    attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_STATUS, status);
    Point[] aPoints = gl.getCoo();
    if (aPoints == null) {
      // Для отладки
      throw new NullPointerException(gl + " :has got null point array");
    }
    if (aPoints.length > 0) {
      attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_COORDS, aPoints);
    }
    Boolean bEditable = gl.isEditable();
    attributeHolder.addAttr(AttributeHolder.Attribute.ATTR_EDIT, bEditable);

    return attributeHolder;
  }
Exemplo n.º 2
0
 /**
  * Применить атрибуты к клифу
  *
  * @param glyph Глиф, к которому применяются атрибуты
  */
 protected void applyAttributesToGlyph(Glyph glyph) {
   HashMap attrMap = attrHolder.getAttrMap();
   Set keySet = attrMap.keySet();
   for (Object aSet : keySet) {
     try {
       AttributeHolder.Attribute attrId = (AttributeHolder.Attribute) aSet;
       applyAttributeToGlyph(glyph, attrId);
     } catch (ClassCastException ex) {
       logger.debug(ex.getMessage(), ex);
     }
   }
 }
Exemplo n.º 3
0
  /**
   * Применить атрибут глифу
   *
   * @param glyph Глиф
   * @param attrId Аттрибут
   */
  protected void applyAttributeToGlyph(Glyph glyph, AttributeHolder.Attribute attrId) {
    HashMap attrMap = attrHolder.getAttrMap();
    switch (attrId) {
      case ATTR_UID:
        Integer uid = (Integer) attrMap.get(attrId);
        glyph.setId(uid);
        break;

      case ATTR_TYPE:
        Integer type = (Integer) attrMap.get(attrId);
        glyph.setType(type);
        break;

      case ATTR_COLOR:
        Color color = (Color) attrMap.get(attrId);
        glyph.setColor(color);
        break;

      case ATTR_TEXT:
        String text = (String) attrMap.get(attrId);
        glyph.setText(text);
        break;

      case ATTR_STATUS:
        Integer intVal = (Integer) attrMap.get(attrId);
        glyph.setStatus(intVal);
        break;

      case ATTR_COORDS:
        Point[] aPoints = (Point[]) attrMap.get(attrId);
        glyph.setCoo(aPoints);
        break;

      case ATTR_EDIT:
        Boolean b = (Boolean) attrMap.get(attrId);
        glyph.setEditable(b);
        break;
    }
  }
Exemplo n.º 4
0
 /**
  * @param attr значение атрибута
  * @return получить значение атрибута
  */
 public Object getAttributeValue(AttributeHolder.Attribute attr) {
   return attrHolder.getAttrValue(attr);
 }
Exemplo n.º 5
0
 /**
  * Установить атрибут
  *
  * @param attr Атрибут
  * @param value Новое значение атрибута
  */
 public void setAttibuteValue(AttributeHolder.Attribute attr, Object value) {
   attrHolder.setAttrValue(attr, value);
 }
Exemplo n.º 6
0
 /**
  * Удаление атрибута
  *
  * @param attrId Идентификатор атрибута
  */
 public void removeAttr(AttributeHolder.Attribute attrId) {
   attrHolder.removeAttr(attrId);
 }
Exemplo n.º 7
0
 /**
  * Добавить атриьут
  *
  * @param attrId Идентификатор атрибута
  * @param attrValue Значение атрибута
  */
 public void addAttr(AttributeHolder.Attribute attrId, Object attrValue) {
   attrHolder.addAttr(attrId, attrValue);
 }