コード例 #1
0
 public void setPaintSequence(final Node paletteNode) {
   if (paletteNode != null) {
     List colorNodes = paletteNode.selectNodes(ChartDefinition.COLOR_NODE_NAME);
     Paint[] paints = new Paint[colorNodes.size()];
     for (int i = 0; i < colorNodes.size(); i++) {
       paints[i] = JFreeChartEngine.getPaint((Node) colorNodes.get(i));
     }
     setPaintSequence(paints);
   }
 }
コード例 #2
0
  private void setChartAttributes(final Node chartAttributes) {
    if (chartAttributes == null) {
      return;
    }
    // get the chart type from the chart node -- this overrides the current
    // chart type
    setChartType(chartAttributes.selectSingleNode(ChartDefinition.TYPE_NODE_NAME));

    // set the chart background
    setChartBackground(
        chartAttributes.selectSingleNode(ChartDefinition.CHART_BACKGROUND_NODE_NAME));

    // set the plot background
    setPlotBackground(chartAttributes.selectSingleNode(ChartDefinition.PLOT_BACKGROUND_NODE_NAME));

    // set the orientation
    setOrientation(chartAttributes.selectSingleNode(XYChartDefinition.ORIENTATION_NODE_NAME));

    // do we want a legend
    setLegendIncluded(chartAttributes.selectSingleNode(ChartDefinition.INCLUDE_LEGEND_NODE_NAME));

    // get the chart title
    setTitle(chartAttributes.selectSingleNode(ChartDefinition.TITLE_NODE_NAME));

    // A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element
    // (for XML schema to
    // be well constructed and validate the XML .
    // We have deprecated <subtitle> as a child of the main node , and now require a <subtitles>
    // parent node
    // under which <subtitle> can exist.

    List subtitles = chartAttributes.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);

    if ((subtitles == null) || (subtitles.isEmpty())) {
      Node subTitlesNode = chartAttributes.selectSingleNode(ChartDefinition.SUBTITLES_NODE_NAME);
      if (subTitlesNode != null) {
        subtitles = subTitlesNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
      }
    } else {
      // log a deprecation warning for this property...
      getLogger()
          .warn(
              Messages.getInstance()
                  .getString(
                      "CHART.WARN_DEPRECATED_CHILD",
                      ChartDefinition.SUBTITLE_NODE_NAME,
                      ChartDefinition.SUBTITLES_NODE_NAME)); // $NON-NLS-1$
      getLogger()
          .warn(
              Messages.getInstance()
                  .getString(
                      "CHART.WARN_PROPERTY_WILL_NOT_VALIDATE",
                      ChartDefinition.SUBTITLE_NODE_NAME)); // $NON-NLS-1$
    }

    if (subtitles != null) {
      addSubTitles(subtitles);
    }

    // get the paint sequence
    setPaintSequence(chartAttributes.selectSingleNode(ChartDefinition.PALETTE_NODE_NAME));
    Node backgroundAlphaNode =
        chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME);
    Node foregroundAlphaNode =
        chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME);

    if (backgroundAlphaNode != null) {
      setBackgroundAlpha(
          chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME));
    }
    if (foregroundAlphaNode != null) {
      setForegroundAlpha(
          chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME));
    }
    // get the stacked value
    setStacked(chartAttributes.selectSingleNode(ChartDefinition.STACKED_NODE_NAME));

    // get the 3D value
    setThreeD(chartAttributes.selectSingleNode(ChartDefinition.THREED_NODE_NAME));

    // set the width
    setWidth(chartAttributes.selectSingleNode(ChartDefinition.WIDTH_NODE_NAME));

    // set the height
    setHeight(chartAttributes.selectSingleNode(ChartDefinition.HEIGHT_NODE_NAME));

    // set the dot width
    setDotWidth(chartAttributes.selectSingleNode(ChartDefinition.DOT_WIDTH_NODE_NAME));

    // set the dot height
    setDotHeight(chartAttributes.selectSingleNode(ChartDefinition.DOT_HEIGHT_NODE_NAME));

    // set vertical tick labels flag
    setDomainVerticalTickLabels(
        chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));

    // set the border on or off
    setBorderVisible(
        chartAttributes.selectSingleNode(ChartDefinition.CHART_BORDER_VISIBLE_NODE_NAME));

    // set the border Paint
    setBorderPaint(
        JFreeChartEngine.getPaint(
            chartAttributes.selectSingleNode(XYChartDefinition.CHART_BORDER_PAINT_NODE_NAME)));

    // set the title location
    setTitlePosition(chartAttributes.selectSingleNode(ChartDefinition.TITLE_POSITION_NODE_NAME));

    // set the legend location
    setLegendPosition(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_POSITION_NODE_NAME));

    // set the title font
    setTitleFont(chartAttributes.selectSingleNode(ChartDefinition.TITLE_FONT_NODE_NAME));

    // set the domain title
    setDomainTitle(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_NODE_NAME));

    // set the domain font
    setDomainTitleFont(
        chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_FONT_NODE_NAME));

    // set the range title
    setRangeTitle(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_NODE_NAME));

    // the the range font
    setRangeTitleFont(
        chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_FONT_NODE_NAME));

    // set the range minimum
    setRangeMinimum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MINIMUM_NODE_NAME));

    // set the range minimum
    setRangeMaximum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MAXIMUM_NODE_NAME));

    // set the date minimum
    setDateMinimum(
        chartAttributes.selectSingleNode(
            TimeSeriesCollectionChartDefinition.DATE_MINIMUM_NODE_NAME));

    // set the date minimum
    setDateMaximum(
        chartAttributes.selectSingleNode(
            TimeSeriesCollectionChartDefinition.DATE_MAXIMUM_NODE_NAME));

    // set the Period type
    setDomainPeriodType(
        chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_PERIOD_TYPE_NODE_NAME));

    // set the line style
    setLineStyle(chartAttributes.selectSingleNode(ChartDefinition.LINE_STYLE_NODE_NAME));

    // set the line width
    setLineWidth(chartAttributes.selectSingleNode(ChartDefinition.LINE_WIDTH_NODE_NAME));

    // set the marker visibility
    setMarkersVisible(chartAttributes.selectSingleNode(ChartDefinition.MARKER_VISIBLE_NODE_NAME));

    // set legend font
    setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME));

    // set legend border visible
    setLegendBorderVisible(
        chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME));

    setTooltipContent(
        chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_CONTENT_NODE_NAME));

    setTooltipYFormat(
        chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_Y_FORMAT_NODE_NAME));

    setTooltipXFormat(
        chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_X_FORMAT_NODE_NAME));
  }