List of usage examples for org.dom4j Node selectSingleNode
Node selectSingleNode(String xpathExpression);
selectSingleNode
evaluates an XPath expression and returns the result as a single Node
instance.
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupYRightAxis(Chart c, Node root, IPentahoResultSet data) { if (root.selectSingleNode("/chart/y-axis-right") != null) { YAxis y_axis_right = new YAxis(); c.setYAxisRight(y_axis_right);//from ww w .j a va 2 s.c o m Node rightstepsNode = root.selectSingleNode("/chart/y-axis-right/y-steps"); Node rightyMaxNode = root.selectSingleNode("/chart/y-axis-right/y-max"); Node rightyMinNode = root.selectSingleNode("/chart/y-axis-right/y-min"); Node rightyLablesNode = root.selectSingleNode("/chart/y-axis-right/labels"); if (getValue(rightyMaxNode) != null) { y_axis_right.setMax(Integer.valueOf(getNodeValue(rightyMaxNode))); } if (getValue(rightyMinNode) != null) { y_axis_right.setMin(Integer.valueOf(getNodeValue(rightyMinNode))); } if (getValue(rightstepsNode) != null) { y_axis_right.setSteps(Integer.valueOf(getNodeValue(rightstepsNode))); } else y_axis_right.setSteps(Integer.valueOf(10)); if (getValue(rightyLablesNode) != null) { addLabels(y_axis_right, rightyLablesNode); } } }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupBackground(Chart c, Node root) { Node bgNode = root.selectSingleNode("/chart/chart-background"); if (getValue(bgNode) != null) { c.setBackgroundColour(getNodeValue(bgNode)); }/* ww w. ja v a2 s.c o m*/ }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setTooltip(Node root, Element e) { Node tooltipNode = root.selectSingleNode("/chart/tooltip"); if (tooltipNode != null && tooltipNode.getText().length() > 0) { String tooltip = tooltipNode.getText().trim(); e.setTooltip(tooltip);/*from ww w.j a v a2s. c om*/ } else { e.setTooltip("#val#"); } }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupChartText(Chart c, Node root) { Node chartNode = root.selectSingleNode("/" + OpenFlashChartComponent.CHART_NODE_LOC); Node title = chartNode.selectSingleNode(AbstractChartFactory.TITLE_NODE_LOC); Node titleFont = chartNode.selectSingleNode(AbstractChartFactory.TITLE_FONT_NODE_LOC); Text titleText = new Text(); if (getValue(title) != null) { titleText.setText(getNodeValue(title)); } else {//from ww w. ja v a 2s. c o m // TODO Figure out a default titleText.setText("Title"); } titleText.setStyle(AbstractChartFactory.buildCSSStringFromNode(titleFont)); c.setTitle(titleText); }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupXAxis(Chart c, Node root, IPentahoResultSet data) { setXLegend(c, root);// ww w . j a v a2 s. c om XAxis xaxis = new XAxis(); c.setXAxis(xaxis); setXAxisLabels(c, root, data); Node stepsNode = root.selectSingleNode("/chart/x-axis/x-steps"); Node maxNode = root.selectSingleNode("/chart/x-axis/x-max"); if (stepsNode != null || maxNode != null) setXAxisRange(c, stepsNode, maxNode); setupXAxisColor(c, root); }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupYAxis(Chart c, Node root, IPentahoResultSet data) { setYLegend(c, root);// ww w .ja v a 2 s. co m Node stepsNode = root.selectSingleNode("/chart/y-axis/y-steps"); Node yMaxNode = root.selectSingleNode("/chart/y-axis/y-max"); if (stepsNode != null || yMaxNode != null) setYAxisRange(c, stepsNode, yMaxNode); setupYAxisLabels(c, root, data); }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected static void setYLegend(Chart c, Node root) { Node chartNode = root.selectSingleNode("/" + OpenFlashChartComponent.CHART_NODE_LOC); // in the Pentaho chart, range-title equals yLengend title Node rangeTitle = chartNode.selectSingleNode(AbstractChartFactory.RANGE_TITLE_NODE_LOC); Node rangeTitleFont = chartNode.selectSingleNode(AbstractChartFactory.RANGE_TITLE_FONT_NODE_LOC); Text rangeText = new Text(); if (getValue(rangeTitle) != null) { rangeText.setText(getNodeValue(rangeTitle)); } else {/*from w w w . j av a2 s . co m*/ // TODO set it to ?? rangeText.setText("Range Title"); } rangeText.setStyle(BarChartFactory.buildCSSStringFromNode(rangeTitleFont)); c.setYLegend(rangeText); }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected static void setXLegend(Chart c, Node root) { Node chartNode = root.selectSingleNode("/" + OpenFlashChartComponent.CHART_NODE_LOC); // in the Pentaho chart, domain-title equals xLengend title Node domainTitle = chartNode.selectSingleNode(AbstractChartFactory.DOMAIN_TITLE_NODE_LOC); Node domainTitleFont = chartNode.selectSingleNode(AbstractChartFactory.DOMAIN_TITLE_FONT_NODE_LOC); Text domainText = new Text(); if (getValue(domainTitle) != null) { domainText.setText(getNodeValue(domainTitle)); } else {// w ww . java 2s. c o m // TODO figure out what to do if the header isn't CategoryDataset // domainText.setText(data.getMetaData().getColumnHeaders()[0][0].toString()); } domainText.setStyle(AbstractChartFactory.buildCSSStringFromNode(domainTitleFont)); c.setXLegend(domainText); }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected void setupYAxisLabels(Chart c, Node root, IPentahoResultSet data) { if (root.selectSingleNode("/chart/y-axis") != null) { YAxis axis = c.getYAxis();//from ww w . j a v a 2 s .c om if (axis == null) { axis = new YAxis(); c.setYAxis(axis); } Node colIndexNode = root.selectSingleNode("/chart/y-axis/labels/sql-column-index"); if (colIndexNode != null && colIndexNode.getText().length() > 0) { int index = Integer.parseInt(colIndexNode.getText().trim()); int rowCount = data.getRowCount(); String[] labels = new String[rowCount]; for (int j = 0; j < rowCount; j++) { Object obj = data.getValueAt(j, index - 1); if (obj instanceof java.sql.Timestamp || obj instanceof java.util.Date) { labels[j] = sf.format(obj); } else { labels[j] = obj.toString(); } } axis.setLabels(labels); } else if (getValue(root.selectSingleNode("/chart/y-axis/labels/values")) != null) { axis.setLabels(fillLabels(root.selectSingleNode("/chart/y-axis/labels/values"))); } Node colorNode = root.selectSingleNode("/chart/y-axis/color"); if (colorNode != null && colorNode.getText().length() > 2) { axis.setColour(colorNode.getText().trim()); } } }
From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java
License:Open Source License
protected static void setXAxisLabels(Chart c, Node root, IPentahoResultSet data) { if (root.selectSingleNode("/chart/x-axis") != null) { XAxis axis = c.getXAxis();/*from w w w. j av a 2s . c om*/ if (axis == null) { axis = new XAxis(); c.setXAxis(axis); } Node colIndexNode = root.selectSingleNode("/chart/x-axis/labels/sql-column-index"); if (colIndexNode != null && colIndexNode.getText().length() > 0) { int index = Integer.parseInt(colIndexNode.getText().trim()); int rowCount = data.getRowCount(); String[] labels = new String[rowCount]; for (int j = 0; j < rowCount; j++) { Object obj = data.getValueAt(j, index - 1); if (obj instanceof java.sql.Timestamp || obj instanceof java.util.Date) { labels[j] = sf.format(obj); } else { labels[j] = obj.toString(); } } axis.setLabels(labels); } else if (getValue(root.selectSingleNode("/chart/x-axis/labels/values")) != null) { axis.setLabels(fillLabels(root.selectSingleNode("/chart/x-axis/labels/values"))); } Node colorNode = root.selectSingleNode("/chart/x-axis/color"); if (colorNode != null && colorNode.getText().length() > 2) { axis.setColour(colorNode.getText().trim()); } } }