Package org.geomajas.internal.rendering.writer.vml.geometry

Source Code of org.geomajas.internal.rendering.writer.vml.geometry.PolygonWriter

/*
* This is part of Geomajas, a GIS framework, http://www.geomajas.org/.
*
* Copyright 2008-2011 Geosparc nv, http://www.geosparc.com/, Belgium.
*
* The program is available in open source according to the GNU Affero
* General Public License. All contributions in this program are covered
* by the Geomajas Contributors License Agreement. For full licensing
* details, see LICENSE.txt in the project root.
*/
package org.geomajas.internal.rendering.writer.vml.geometry;

import org.geomajas.internal.rendering.writer.GraphicsWriter;
import org.geomajas.rendering.GraphicsDocument;
import org.geomajas.rendering.RenderException;

import com.vividsolutions.jts.geom.LineString;
import com.vividsolutions.jts.geom.Polygon;

/**
* <p>
* VML writer for <code>Polygon</code> objects.
* </p>
*
* @author Pieter De Graef
* @author Jan De Moerloose
*/
public class PolygonWriter implements GraphicsWriter {

  /**
   * Writes the object to the specified document, optionally creating a child
   * element. The object in this case should be a polygon.
   *
   * @param o the object (of type Polygon).
   * @param document the document to write to.
   * @param asChild create child element if true.
   * @throws RenderException
   */
  public void writeObject(Object o, GraphicsDocument document, boolean asChild) throws RenderException {
    document.writeElement("vml:shape", asChild);
    document.writeAttribute("fill-rule", "evenodd");
    document.writeAttributeStart("path");
    Polygon poly = (Polygon) o;
    LineString shell = poly.getExteriorRing();
    int nHoles = poly.getNumInteriorRing();
    document.writeClosedPathContent(shell.getCoordinates());
    for (int j = 0; j < nHoles; j++) {
      document.writeClosedPathContent(poly.getInteriorRingN(j).getCoordinates());
    }
    document.writeAttributeEnd();
  }
}
TOP

Related Classes of org.geomajas.internal.rendering.writer.vml.geometry.PolygonWriter

TOP
Copyright © 2018 www.massapi.com. 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.