Example usage for org.w3c.dom Element setAttributeNS

List of usage examples for org.w3c.dom Element setAttributeNS

Introduction

In this page you can find the example usage for org.w3c.dom Element setAttributeNS.

Prototype

public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException;

Source Link

Document

Adds a new attribute.

Usage

From source file:org.eclipse.smila.datamodel.record.dom.RecordBuilder.java

/**
 * Builds the record as document element.
 *
 * @param factory//  w  w  w  . j a  va  2 s.co m
 *          the factory
 * @param record
 *          the record
 */
public void buildRecordAsDocumentElement(final Document factory, final Record record) {
    final Element recordElement = buildRecord(factory, record);
    recordElement.setAttribute(ATTRIBUTE_VERSION, SCHEMA_VERSION_RECORD);
    recordElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, ATTRIBUTE_XMLNSREC, NAMESPACE_RECORD);
    factory.appendChild(recordElement);
}

From source file:org.eclipse.smila.datamodel.xml.DOMRecordWriter.java

/**
 * Builds the record as document element.
 * //  w  w w  .  j av a2s.c  om
 * @param factory
 *          the factory
 * @param record
 *          the record
 */
public void buildRecordAsDocumentElement(final Document factory, final Record record) {
    final Element recordElement = buildRecord(factory, record);
    recordElement.setAttribute(XmlConstants.ATTRIBUTE_VERSION, XmlConstants.SCHEMA_VERSION_RECORD);
    recordElement.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XmlConstants.ATTRIBUTE_XMLNSREC,
            XmlConstants.NAMESPACE_RECORD);
    factory.appendChild(recordElement);
}

From source file:org.eclipse.swordfish.plugins.compression.CompressorImpl.java

public Source asCompressedSource(Source src, int sizeThreshold) {
    try {/*w w w  .  j a  v  a 2s.c om*/
        if (!isExceedSizeThreshold(src, sizeThreshold)) {
            return null;
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        GZIPOutputStream zipped = new GZIPOutputStream(baos);
        Result result = new StreamResult(zipped);
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer = tf.newTransformer();
        transformer.transform(src, result);
        zipped.finish();
        byte[] compressedBytes = baos.toByteArray();
        String encoded = new String(new Base64().encode(compressedBytes));
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element wrapper = doc.createElementNS(CompressionConstants.COMPRESSION_NS,
                CompressionConstants.COMPRESSION_ELEMENT_PREFIX + ":"
                        + CompressionConstants.COMPRESSED_ELEMENT);
        wrapper.setAttributeNS("http://www.w3.org/2000/xmlns/",
                "xmlns:" + CompressionConstants.COMPRESSION_ELEMENT_PREFIX,
                CompressionConstants.COMPRESSION_NS);
        wrapper.appendChild(doc.createTextNode(encoded));
        doc.appendChild(wrapper);
        return new DOMSource(doc);
    } catch (Exception e) {
        LOG.error("Couldn't compress source", e);
        throw new SwordfishException("Couldn't compress source", e);
    }
}

From source file:org.exoplatform.calendar.service.impl.RemoteCalendarServiceImpl.java

public MultiStatus doCalendarMultiGet(HttpClient client, String uri, String[] hrefs) throws Exception {

    if (hrefs.length == 0)
        return null;

    ReportMethod report = null;/*w w w.j  av a  2 s.  c  om*/

    try {
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.newDocument();

        // root element
        Element calendarMultiGet = DomUtil.createElement(doc, CALDAV_XML_CALENDAR_MULTIGET, CALDAV_NAMESPACE);
        calendarMultiGet.setAttributeNS(Namespace.XMLNS_NAMESPACE.getURI(),
                Namespace.XMLNS_NAMESPACE.getPrefix() + ":" + DavConstants.NAMESPACE.getPrefix(),
                DavConstants.NAMESPACE.getURI());

        ReportInfo reportInfo = new ReportInfo(calendarMultiGet, DavConstants.DEPTH_0);
        DavPropertyNameSet propNameSet = reportInfo.getPropertyNameSet();
        propNameSet.add(DavPropertyName.GETETAG);
        DavPropertyName calendarData = DavPropertyName.create(CALDAV_XML_CALENDAR_DATA, CALDAV_NAMESPACE);
        propNameSet.add(calendarData);

        Element href;
        for (int i = 0; i < hrefs.length; i++) {
            href = DomUtil.createElement(doc, DavConstants.XML_HREF, DavConstants.NAMESPACE, hrefs[i]);
            reportInfo.setContentElement(href);
        }

        report = new ReportMethod(uri, reportInfo);
        client.executeMethod(report);
        MultiStatus multiStatus = report.getResponseBodyAsMultiStatus();
        return multiStatus;
    } finally {
        if (report != null)
            report.releaseConnection();
    }
}

From source file:org.exoplatform.calendar.service.impl.RemoteCalendarServiceImpl.java

/**
 * Make the new REPORT method object to query calendar component on CalDav server
 * @param uri the URI to the calendar collection on server 
 * @param from start date of the time range to filter calendar components
 * @param to end date of the time range to filter calendar components
 * @return ReportMethod object/*from   www. ja  va  2s. co  m*/
 * @throws Exception
 */
public ReportMethod makeCalDavQueryReport(String uri, java.util.Calendar from, java.util.Calendar to)
        throws Exception {
    ReportMethod report = null;
    try {
        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
        Document doc = docBuilder.newDocument();

        // root element
        Element calendarQuery = DomUtil.createElement(doc, CALDAV_XML_CALENDAR_QUERY, CALDAV_NAMESPACE);
        calendarQuery.setAttributeNS(Namespace.XMLNS_NAMESPACE.getURI(),
                Namespace.XMLNS_NAMESPACE.getPrefix() + ":" + DavConstants.NAMESPACE.getPrefix(),
                DavConstants.NAMESPACE.getURI());

        ReportInfo reportInfo = new ReportInfo(calendarQuery, DavConstants.DEPTH_0);
        DavPropertyNameSet propNameSet = reportInfo.getPropertyNameSet();
        propNameSet.add(DavPropertyName.GETETAG);

        // filter element
        Element filter = DomUtil.createElement(doc, CALDAV_XML_FILTER, CALDAV_NAMESPACE);

        Element calendarComp = DomUtil.createElement(doc, CALDAV_XML_COMP_FILTER, CALDAV_NAMESPACE);
        calendarComp.setAttribute(CALDAV_XML_COMP_FILTER_NAME, net.fortuna.ical4j.model.Calendar.VCALENDAR);

        Element eventComp = DomUtil.createElement(doc, CALDAV_XML_COMP_FILTER, CALDAV_NAMESPACE);
        eventComp.setAttribute(CALDAV_XML_COMP_FILTER_NAME, net.fortuna.ical4j.model.component.VEvent.VEVENT);

        Element todoComp = DomUtil.createElement(doc, CALDAV_XML_COMP_FILTER, CALDAV_NAMESPACE);
        todoComp.setAttribute(CALDAV_XML_COMP_FILTER_NAME, net.fortuna.ical4j.model.component.VEvent.VTODO);

        Element timeRange = DomUtil.createElement(doc, CALDAV_XML_TIME_RANGE, CALDAV_NAMESPACE);
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss'Z'");
        timeRange.setAttribute(CALDAV_XML_START, format.format(from.getTime()));
        timeRange.setAttribute(CALDAV_XML_END, format.format(to.getTime()));

        eventComp.appendChild(timeRange);
        todoComp.appendChild(timeRange);
        calendarComp.appendChild(eventComp);
        calendarComp.appendChild(todoComp);
        filter.appendChild(calendarComp);

        reportInfo.setContentElement(filter);
        report = new ReportMethod(uri, reportInfo);
        return report;
    } catch (Exception e) {
        if (logger.isDebugEnabled())
            logger.debug("Cannot build report method for CalDav query", e);
        return null;
    }
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * The constructor builds the DOM of the SVG.
 * //from w ww  .j a v a2  s  . co m
 * @param f
 */
public FireChartSVG(AbstractFireHistoryReader f) {

    // Initialize the builder objects
    compositePlotEB = new CompositePlotElementBuilder(this);
    legendEB = new LegendElementBuilder(this);
    percentScarredPlotEB = new PercentScarredPlotElementBuilder(this);
    sampleRecorderPlotEB = new SampleRecorderPlotElementBuilder(this);
    seriesEB = new SeriesElementBuilder(this);
    timeAxisEB = new TimeAxisElementBuilder(this);

    // Assign number for message passing from ECMAscript
    chartNum = chartCounter;
    chartCounter++;

    if (chart_map == null) {
        chart_map = new HashMap<Integer, FireChartSVG>();
    }
    chart_map.put(chartNum, this);

    reader = f;
    ArrayList<FHSeriesSVG> seriesToAdd = FireChartUtil.seriesListToSeriesSVGList(f.getSeriesList());

    if (!seriesSVGList.isEmpty()) {
        seriesSVGList.clear();
    }
    for (int i = 0; i < seriesToAdd.size(); i++) {
        try {
            FHSeries currentSeries = seriesToAdd.get(i);

            // Add the default category entry if the current series has no defined entries (this is necessary for category groupings)
            if (currentSeries.getCategoryEntries().isEmpty()) {
                currentSeries.getCategoryEntries()
                        .add(new FHCategoryEntry(currentSeries.getTitle(), "default", "default"));
            }

            seriesSVGList.add(new FHSeriesSVG(seriesToAdd.get(i), i));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Element svgRoot = doc.getDocumentElement();

    // Set up the scripts for Java / ECMAScript interop
    Element script = doc.createElementNS(svgNS, "script");
    script.setAttributeNS(null, "type", "text/ecmascript");

    try {
        // File script_file = new File("./script.js");

        ClassLoader cl = org.fhaes.neofhchart.svg.FireChartSVG.class.getClassLoader();
        Scanner scanner = new Scanner(cl.getResourceAsStream("script.js"));

        String script_string = "";
        while (scanner.hasNextLine()) {
            script_string += scanner.nextLine();
        }
        script_string += ("var chart_num = " + chartNum + ";");
        Text script_text = doc.createTextNode(script_string);
        script.appendChild(script_text);
        scanner.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    svgRoot.appendChild(script);

    // The padding_grouper is used to add in some padding around the chart as a whole
    Element padding_grouper = doc.createElementNS(svgNS, "g");
    padding_grouper.setAttributeNS(null, "id", "padding_g");
    padding_grouper.setAttributeNS(null, "transform", "translate (" + chartXOffset + ",20)");
    svgRoot.appendChild(padding_grouper);

    // Build grouper to hold annotation elements
    Element annote_g = doc.createElementNS(svgNS, "g");
    annote_g.setAttributeNS(null, "id", "annote_g");
    padding_grouper.appendChild(annote_g);

    // Build chart title
    Element chart_title_g = doc.createElementNS(svgNS, "g");
    chart_title_g.setAttributeNS(null, "id", "chart_title_g");
    padding_grouper.appendChild(chart_title_g);

    // Build the time axis
    Element time_axis_g = doc.createElementNS(svgNS, "g");
    time_axis_g.setAttributeNS(null, "id", "time_axis_g");
    padding_grouper.appendChild(time_axis_g);

    // Build index plot
    Element index_plot_g = doc.createElementNS(svgNS, "g");
    index_plot_g.setAttributeNS(null, "id", "index_plot_g");
    padding_grouper.appendChild(index_plot_g);

    // Build chronology plot
    Element chrono_plot_g = doc.createElementNS(svgNS, "g");
    chrono_plot_g.setAttributeNS(null, "id", "chrono_plot_g");
    padding_grouper.appendChild(chrono_plot_g);

    // Build composite plot
    Element comp_plot_g = doc.createElementNS(svgNS, "g");
    comp_plot_g.setAttributeNS(null, "id", "comp_plot_g");
    padding_grouper.appendChild(comp_plot_g);

    // Build legend
    Element legend_g = doc.createElementNS(svgNS, "g");
    legend_g.setAttributeNS(null, "id", "legend_g");
    padding_grouper.appendChild(legend_g);

    // Finish up the initialization
    buildElements();
    positionSeriesLines();
    positionChartGroupersAndDrawTimeAxis();
    sortSeriesAccordingToPreference();
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * Handles the positioning of the series lines on the chart.
 *///from  w  w w  .  java 2  s  . co  m
private void positionSeriesLines() {

    int series_spacing_and_height = App.prefs.getIntPref(PrefKey.CHART_CHRONOLOGY_PLOT_SPACING, 5)
            + SERIES_HEIGHT;
    int hidden = 0;

    // Reset the amount of padding necessary for category groupings
    categoryGroupPadding = 0;

    // Define a string for keeping track of the category groups
    ArrayList<String> categoryGroupsProcessed = new ArrayList<String>();

    for (int i = 0; i < seriesSVGList.size(); i++) {
        FHSeries seriesSVG = seriesSVGList.get(i);
        Element series_group = doc.getElementById("series_group_" + seriesSVG.getTitle());
        String visibility_string = seriesSVGList.get(i).isVisible() ? "inline" : "none";

        if (seriesSVGList.get(i).isVisible()) {
            // Inject the category group spacing and label text as different category groups are positioned
            if (lastTypeSortedBy == SeriesSortType.CATEGORY
                    && App.prefs.getBooleanPref(PrefKey.CHART_SHOW_CATEGORY_GROUPS, true)) {
                String currentCategoryGroup = seriesSVG.getCategoryEntries().get(0).getContent();

                if (!categoryGroupsProcessed.contains(currentCategoryGroup)) {
                    // Keep track of which category groups have already been processed
                    categoryGroupsProcessed.add(currentCategoryGroup);

                    Element label_text_g = doc.createElementNS(svgNS, "g");
                    label_text_g.setAttributeNS(null, "transform",
                            "translate(0," + Integer.toString(-(CATEGORY_PADDING_AMOUNT / 2)) + ")");

                    // Apply the label coloring as necessary
                    if (App.prefs.getBooleanPref(PrefKey.CHART_AUTOMATICALLY_COLORIZE_LABELS, false)) {
                        Color labelColor = FireChartUtil.pickColorFromInteger(categoryGroupsProcessed.size());
                        label_text_g.appendChild(
                                seriesEB.getCategoryLabelTextElement(currentCategoryGroup, labelColor));
                    } else {
                        label_text_g.appendChild(
                                seriesEB.getCategoryLabelTextElement(currentCategoryGroup, Color.BLACK));
                    }
                    series_group.appendChild(label_text_g);

                    // Handle the padding of category groups depending on whether the label is shown
                    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_CATEGORY_LABELS, true)) {
                        label_text_g.setAttributeNS(null, "display", "inline");
                        categoryGroupPadding += CATEGORY_PADDING_AMOUNT;
                    } else {
                        label_text_g.setAttributeNS(null, "display", "none");
                        categoryGroupPadding += CATEGORY_PADDING_AMOUNT / 2;
                    }
                }
            }

            series_group.setAttributeNS(null, "transform", "translate(0,"
                    + Integer.toString(((i - hidden) * series_spacing_and_height) + categoryGroupPadding)
                    + ")");
        } else {
            hidden++;
        }

        series_group.setAttributeNS(null, "display", visibility_string);
    }
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * Positions the various parts of the fire chart. This method also re-creates the time axis since it is dependent on the total height of
 * the svg, due to the dashed tick lines that run vertically to denote years.
 *//*  w  w  w .j a  va2 s  .  c  om*/
public void positionChartGroupersAndDrawTimeAxis() {

    // Calculate plot dimensions
    int cur_bottom = 0; // used for tracking where the bottom of the chart is as it is being built
    int index_plot_height = App.prefs.getIntPref(PrefKey.CHART_INDEX_PLOT_HEIGHT, 100);
    int series_spacing_and_height = App.prefs.getIntPref(PrefKey.CHART_CHRONOLOGY_PLOT_SPACING, 5)
            + SERIES_HEIGHT;

    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_CHART_TITLE, true)) {
        cur_bottom += App.prefs.getIntPref(PrefKey.CHART_TITLE_FONT_SIZE, 20) + 10;
    }

    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_INDEX_PLOT, true)) {
        cur_bottom += index_plot_height + series_spacing_and_height;
    }

    int chronology_plot_y = cur_bottom;
    int num_visible = 0;

    for (int i = 0; i < seriesSVGList.size(); i++) {
        if (seriesSVGList.get(i).isVisible()) {
            num_visible++;
        }
    }

    int chronology_plot_height = num_visible * series_spacing_and_height + SERIES_HEIGHT;

    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_CHRONOLOGY_PLOT, true)) {
        cur_bottom += chronology_plot_height + series_spacing_and_height + categoryGroupPadding;
    }

    int composite_plot_y = cur_bottom;
    int composite_plot_height = App.prefs.getIntPref(PrefKey.CHART_COMPOSITE_HEIGHT, 70);

    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_COMPOSITE_PLOT, true)) {
        cur_bottom += composite_plot_height + series_spacing_and_height;
    }

    int total_height = cur_bottom + series_spacing_and_height;

    // reset svg dimensions
    Element svgRoot = doc.getDocumentElement();

    // build time axis
    Element time_axis_g = doc.getElementById("time_axis_g");

    // delete everything in the current time axis
    NodeList n = time_axis_g.getChildNodes(); // because getChildNodes doesn't return a seq
    for (int i = 0; i < n.getLength(); i++) { // no, instead we get a non-iterable custom data-structure :(
        time_axis_g.removeChild(n.item(i));
    }

    // add in the new time axis
    time_axis_g.appendChild(getTimeAxis(total_height));

    // set the translations for the chronology plot grouper
    Element chrono_plot_g = doc.getElementById("chrono_plot_g");
    chrono_plot_g.setAttributeNS(null, "transform", "translate(0," + chronology_plot_y + ")");

    // set the translations for the composite plot grouper
    Element comp_plot_g = doc.getElementById("comp_plot_g");
    comp_plot_g.setAttributeNS(null, "transform", "translate(0," + composite_plot_y + ")");

    // move the legend
    Element legend_g = doc.getElementById("legend_g");
    legend_g.setAttributeNS(null, "transform",
            "translate(" + (chartWidth + 10 + this.widestChronologyLabelSize + 50) + ", " + 0 + ")");

    // set the annote canvas dimensions (so it can catch key bindings)
    Element annote_canvas = doc.getElementById("annote_canvas");
    annote_canvas.setAttributeNS(null, "width", Integer.toString(chartWidth));
    annote_canvas.setAttributeNS(null, "height", Integer.toString(total_height));

    // set document dimensions for png and pdf export
    // svgRoot.setAttributeNS(null, "width", (chart_width + this.widestChronologyLabelSize + 150 + 350) + "px");
    svgRoot.setAttributeNS(null, "width", getTotalWidth() + "px");

    int root_height = (total_height + 50 > 400) ? total_height + 50 : 400;
    totalHeight = root_height;
    svgRoot.setAttributeNS(null, "height", root_height + "px");
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * Clear out the groupers and build the chart components.
 */// w  w w  .  j a  v a  2  s.  c  o m
public void buildElements() {

    // Rebuild the annotation canvas
    Element annote_g = doc.getElementById("annote_g");
    deleteAllChildren(annote_g);

    Element canvas = getAnnoteCanvas();
    if (canvas != null) {
        annote_g.appendChild(canvas);
    }

    // Rebuild the chart title
    Element chart_title_g = doc.getElementById("chart_title_g");
    deleteAllChildren(chart_title_g);
    if (App.prefs.getBooleanPref(PrefKey.CHART_TITLE_USE_DEFAULT_NAME, true)) {
        FHFile currentFile = getReader().getFHFile();

        if (currentFile.getSiteName().length() > 0) {
            chart_title_g.appendChild(getChartTitle(currentFile.getSiteName()));
        } else {
            chart_title_g.appendChild(getChartTitle(currentFile.getFileNameWithoutExtension()));
        }
    } else {
        chart_title_g.appendChild(
                getChartTitle(App.prefs.getPref(PrefKey.CHART_TITLE_OVERRIDE_VALUE, "Fire Chart")));
    }
    if (App.prefs.getBooleanPref(PrefKey.CHART_SHOW_CHART_TITLE, true)) {
        chart_title_g.setAttributeNS(null, "display", "inline");
    } else {
        chart_title_g.setAttributeNS(null, "display", "none");
    }

    // Rebuild the index plot
    Element index_plot_g = doc.getElementById("index_plot_g");
    deleteAllChildren(index_plot_g);
    index_plot_g.appendChild(getIndexPlot());

    sortSeriesAccordingToPreference();

    // Rebuild the chronology plot
    rebuildChronologyPlot();

    // Rebuild the composite plot
    Element comp_plot_g = doc.getElementById("comp_plot_g");
    deleteAllChildren(comp_plot_g);
    comp_plot_g.appendChild(getCompositePlot());

    // Rebuild the legend
    Element legend_g = doc.getElementById("legend_g");
    deleteAllChildren(legend_g);
    legend_g.appendChild(getLegend());

    positionChartGroupersAndDrawTimeAxis();
}

From source file:org.fhaes.neofhchart.svg.FireChartSVG.java

/**
 * Builds a series line based of the input seriesSVG object.
 * /*from   w w w.j av  a 2 s  .co m*/
 * @param seriesSVG
 * @return a series line element
 */
private Element buildSingleSeriesLine(FHSeriesSVG seriesSVG) {

    Element series_group = doc.createElementNS(svgNS, "g");
    series_group.setAttributeNS(null, "id", seriesSVG.getTitle());

    // draw in the recording and non-recording lines
    Element line_group = doc.createElementNS(svgNS, "g");
    boolean[] recording_years = seriesSVG.getRecordingYears();

    int begin_index = 0;
    int last_index = recording_years.length - 1;

    if (recording_years.length != 0) {
        if (applyBCYearOffset(seriesSVG.getFirstYear()) < this.getFirstChartYear()) {
            // User has trimmed the start of this data series off
            int firstyear = applyBCYearOffset(seriesSVG.getFirstYear());
            int thisfirstyear = this.getFirstChartYear();
            begin_index = thisfirstyear - firstyear;
        }

        if (applyBCYearOffset(seriesSVG.getLastYear()) > this.getLastChartYear()) {
            // User has trimmed the end of this data series off
            int recleng = recording_years.length;
            int lastyear = applyBCYearOffset(seriesSVG.getLastYear());
            int thislastyear = this.getLastChartYear();
            last_index = recleng - (lastyear - thislastyear) - 1;
        }

        boolean isRecording = recording_years[0];

        for (int j = 0; j <= last_index; j++) {
            if (isRecording != recording_years[j] || j == last_index) {
                // Need to draw a line
                line_group.appendChild(
                        seriesEB.getSeriesLine(isRecording, begin_index, j, seriesSVG.getLineColor()));

                begin_index = j;
                isRecording = recording_years[j];
            }
        }
    }
    series_group.appendChild(line_group);

    // add in fire events
    if (showFires) {
        Element series_fire_events = doc.createElementNS(svgNS, "g");
        boolean[] fire_years = seriesSVG.getEventYears();

        for (int j = 0; j < fire_years.length; j++) {
            if (fire_years[j] && j <= last_index) {
                String translate = "translate(" + Double.toString(j
                        - FireChartUtil.pixelsToYears(0.5, chartWidth, getFirstChartYear(), getLastChartYear()))
                        + "," + Integer.toString(-SERIES_HEIGHT / 2) + ")";

                String scale = "scale("
                        + FireChartUtil.pixelsToYears(chartWidth, getFirstChartYear(), getLastChartYear())
                        + ",1)";

                Element fire_event_g = doc.createElementNS(svgNS, "g");
                fire_event_g.setAttributeNS(null, "class", "fire_marker");
                fire_event_g.setAttributeNS(null, "stroke",
                        FireChartUtil.colorToHexString(seriesSVG.getLineColor()));
                fire_event_g.setAttributeNS(null, "transform", translate + scale);
                fire_event_g.appendChild(seriesEB.getFireYearMarker(seriesSVG.getLineColor()));
                series_fire_events.appendChild(fire_event_g);
            }
        }
        series_group.appendChild(series_fire_events);
    }

    // add in injury events
    if (showInjuries) {
        Element series_injury_events = doc.createElementNS(svgNS, "g");
        boolean[] injury_years = seriesSVG.getInjuryYears();
        for (int j = 0; j < injury_years.length; j++) {
            if (injury_years[j] && j <= last_index) {
                String translate = "translate(" + Double.toString(j
                        - FireChartUtil.pixelsToYears(1.5, chartWidth, getFirstChartYear(), getLastChartYear()))
                        + "," + Integer.toString(-SERIES_HEIGHT / 2) + ")";

                String scale = "scale("
                        + FireChartUtil.pixelsToYears(chartWidth, getFirstChartYear(), getLastChartYear())
                        + ",1)";

                Element injury_event_g = doc.createElementNS(svgNS, "g");
                injury_event_g.setAttributeNS(null, "class", "injury_marker");
                injury_event_g.setAttributeNS(null, "stroke",
                        FireChartUtil.colorToHexString(seriesSVG.getLineColor()));
                injury_event_g.setAttributeNS(null, "transform", translate + scale);
                injury_event_g.appendChild(seriesEB.getInjuryYearMarker(3, seriesSVG.getLineColor()));

                series_injury_events.appendChild(injury_event_g);
            }
        }
        series_group.appendChild(series_injury_events);
    }

    // add in inner year pith marker
    if (showPith && seriesSVG.hasPith() || showInnerRing && !seriesSVG.hasPith()) {
        if (applyBCYearOffset(seriesSVG.getFirstYear()) >= getFirstChartYear()) {
            // no translation because the inner year is at year=0
            String translate = "translate(" + (0
                    - FireChartUtil.pixelsToYears(0.5, chartWidth, getFirstChartYear(), getLastChartYear()))
                    + ",0)";

            String scale = "scale("
                    + FireChartUtil.pixelsToYears(chartWidth, getFirstChartYear(), getLastChartYear()) + ",1)";

            Element pith_marker_g = doc.createElementNS(svgNS, "g");
            pith_marker_g.setAttributeNS(null, "transform", translate + scale);
            pith_marker_g.appendChild(
                    seriesEB.getInnerYearPithMarker(seriesSVG.hasPith(), 5, seriesSVG.getLineColor()));
            series_group.appendChild(pith_marker_g);
        }
    }

    // add in outer year bark marker
    if ((showBark && seriesSVG.hasBark()) || (showOuterRing && !seriesSVG.hasBark())) {
        if (applyBCYearOffset(seriesSVG.getLastYear()) <= this.getLastChartYear()) {
            String translate = "translate("
                    + (applyBCYearOffset(seriesSVG.getLastYear()) - applyBCYearOffset(seriesSVG.getFirstYear()))
                    + ",0)";

            String scale = "scale("
                    + FireChartUtil.pixelsToYears(chartWidth, getFirstChartYear(), getLastChartYear()) + ",1)";

            Element bark_marker_g = doc.createElementNS(svgNS, "g");
            bark_marker_g.setAttribute("transform", translate + scale);
            bark_marker_g.appendChild(
                    seriesEB.getOuterYearBarkMarker(seriesSVG.hasBark(), 5, seriesSVG.getLineColor()));
            series_group.appendChild(bark_marker_g);
        }
    }

    return series_group;
}