Exemplo n.º 1
0
  /**
   * derive parameter id for a given InPUT element.
   *
   * @param element
   * @param name
   * @return
   */
  private static String deriveParamId(final Element element, String name) {
    // 1) not null, 2) is Element, 3) not root -> next!
    if (element.getParent() != null && element.getParent() instanceof Element) {
      Element parent = (Element) element.getParent();
      if (!parent.isRootElement())
        name = deriveParamId(parent, parent.getAttributeValue(Q.ID_ATTR) + "." + name);
    }

    return name;
  }
  /**
   * Instantiates a new reserved numbers pane.
   *
   * @param reElement the re element
   */
  public ReservedNumbersPane(Element reElement) {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.reservedNumbersElement = reElement;

    saveButton = new SaveButton();
    saveButton.setEnabled(false);
    saveButton.addActionListener(this);
    saveButton.setAlignmentX(Component.CENTER_ALIGNMENT);

    List<Element> editors =
        ((Element) reservedNumbersElement.getParent()).getChild("EDITORS").getChildren("EDITOR");
    ElementFacade ef = new ElementFacade(reservedNumbersElement, saveButton, null, RESERVEDNUMBERS);
    numbersField = new StringField(ef, editors, new Dimension(700, 200), true);
    add(numbersField);
    add(saveButton);
  }
Exemplo n.º 3
0
 public String getFamilyComment() {
   return ((Element) _element.getParent()).getAttributeValue("comment");
 }
Exemplo n.º 4
0
  /*
   * (non-Javadoc)
   * @see com.rometools.rome.io.ModuleGenerator#generate(com.rometools.rome.feed.module.Module,
   * org.jdom2.Element)
   */
  @Override
  public void generate(final Module module, final Element element) {
    // this is not necessary, it is done to avoid the namespace definition
    // in every item.
    Element root = element;
    while (root.getParent() != null && root.getParent() instanceof Element) {
      root = (Element) element.getParent();
    }
    root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);
    root.addNamespaceDeclaration(GeoRSSModule.GML_NS);

    final Element whereElement = new Element("where", GeoRSSModule.SIMPLE_NS);
    element.addContent(whereElement);

    final GeoRSSModule geoRSSModule = (GeoRSSModule) module;
    final AbstractGeometry geometry = geoRSSModule.getGeometry();

    if (geometry instanceof Point) {
      final Position pos = ((Point) geometry).getPosition();

      final Element pointElement = new Element("Point", GeoRSSModule.GML_NS);
      whereElement.addContent(pointElement);

      final Element posElement = new Element("pos", GeoRSSModule.GML_NS);
      posElement.addContent(
          String.valueOf(pos.getLatitude()) + " " + String.valueOf(pos.getLongitude()));
      pointElement.addContent(posElement);
    } else if (geometry instanceof LineString) {
      final PositionList posList = ((LineString) geometry).getPositionList();

      final Element lineElement = new Element("LineString", GeoRSSModule.GML_NS);
      lineElement.addContent(createPosListElement(posList));
      whereElement.addContent(lineElement);
    } else if (geometry instanceof Polygon) {
      final Element polygonElement = new Element("Polygon", GeoRSSModule.GML_NS);
      {
        final AbstractRing ring = ((Polygon) geometry).getExterior();
        if (ring instanceof LinearRing) {
          final Element exteriorElement = new Element("exterior", GeoRSSModule.GML_NS);
          polygonElement.addContent(exteriorElement);
          final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
          exteriorElement.addContent(ringElement);
          ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));

        } else {
          System.err.println(
              "GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
        }
      }
      final List<AbstractRing> interiorList = ((Polygon) geometry).getInterior();
      final Iterator<AbstractRing> it = interiorList.iterator();
      while (it.hasNext()) {
        final AbstractRing ring = it.next();
        if (ring instanceof LinearRing) {
          final Element interiorElement = new Element("interior", GeoRSSModule.GML_NS);
          polygonElement.addContent(interiorElement);
          final Element ringElement = new Element("LinearRing", GeoRSSModule.GML_NS);
          interiorElement.addContent(ringElement);
          ringElement.addContent(createPosListElement(((LinearRing) ring).getPositionList()));

        } else {
          System.err.println(
              "GeoRSS GML format can't handle rings of type: " + ring.getClass().getName());
        }
      }
      whereElement.addContent(polygonElement);
    } else if (geometry instanceof Envelope) {
      final Envelope envelope = (Envelope) geometry;
      final Element envelopeElement = new Element("Envelope", GeoRSSModule.GML_NS);
      whereElement.addContent(envelopeElement);

      final Element lowerElement = new Element("lowerCorner", GeoRSSModule.GML_NS);
      lowerElement.addContent(
          String.valueOf(envelope.getMinLatitude())
              + " "
              + String.valueOf(envelope.getMinLongitude()));
      envelopeElement.addContent(lowerElement);

      final Element upperElement = new Element("upperCorner", GeoRSSModule.GML_NS);
      upperElement.addContent(
          String.valueOf(envelope.getMaxLatitude())
              + " "
              + String.valueOf(envelope.getMaxLongitude()));
      envelopeElement.addContent(upperElement);

    } else {
      System.err.println(
          "GeoRSS GML format can't handle geometries of type: " + geometry.getClass().getName());
    }
  }