report.java
来自「优秀的打印控件全源代码,类似水晶表的设计器!」· Java 代码 · 共 1,537 行 · 第 1/5 页
JAVA
1,537 行
} } } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("background")) { // Load background band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("background"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("title")) { // Load title band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("title"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("pageHeader")) { // Load pageHeader band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("pageHeader"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("columnHeader")) { // Load columnHeader band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("columnHeader"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("detail")) { // Load detail band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("detail"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("columnFooter")) { // Load columnFooter band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("columnFooter"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("pageFooter")) { // Load pageFooter band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("pageFooter"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } else if (node.getNodeType() == Node.ELEMENT_NODE && node.getNodeName().equals("summary")) { // Load summary band NodeList list_child = node.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node bandNode = (Node)list_child.item(ck); if (bandNode.getNodeType() == Node.ELEMENT_NODE && bandNode.getNodeName().equals("band")) { // Read the band... NamedNodeMap bandAttributes = bandNode.getAttributes(); Band b = this.getBandByName("summary"); if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if ( bandAttributes.getNamedItem("isSplitAllowed") != null) b.setSplitAllowed( bandAttributes.getNamedItem("isSplitAllowed").getNodeValue().equals("true") ); readBandElements(bandNode,b); } } } NodeList children = node.getChildNodes(); if (children != null) { for (int i=0; i< children.getLength(); i++) traverse(children.item(i)); } } private void readBandElements(Node bandNode, Band band) { NodeList list_child = bandNode.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node child = (Node)list_child.item(ck); if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("printWhenExpression")) { // Read the band... //NamedNodeMap bandAttributes = bandNode.getAttributes(); //if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); // Take subelements and lloking for the expression... NodeList childsOfChild = child.getChildNodes(); for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) { Node child_child = (Node)childsOfChild.item(c_count); if (child_child.getNodeType() == Node.CDATA_SECTION_NODE || child_child.getNodeType() == Node.TEXT_NODE) { band.setPrintWhenExpression(child_child.getNodeValue()); } } } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("staticText")) { StaticTextReportElement re = new StaticTextReportElement(0,0,0,0); re.setIReportFont(defaultFont); re.setBand(band); NodeList childsOfChild = child.getChildNodes(); for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) { Node child_child = (Node)childsOfChild.item(c_count); if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) { readXMLReportElement(child_child,re); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("textElement")) { readXMLTextElement(child_child,re); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("text")) { re.setText( readPCDATA(child_child, false) ); } } re.setPosition(re.position); re.trasform(new java.awt.Point(0,0),TransformationType.TRANSFORMATION_RESIZE_SE); elements.addElement(re); } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("image")) { ImageReportElement re = new ImageReportElement(0,0,0,0); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); if (nodeAttributes.getNamedItem("isUsingCache") != null) re.setIsUsingCache( (""+nodeAttributes.getNamedItem("isUsingCache").getNodeValue()).equals("true") ); if (nodeAttributes.getNamedItem("scaleImage") != null) re.setScaleImage(""+nodeAttributes.getNamedItem("scaleImage").getNodeValue()); if (nodeAttributes.getNamedItem("vAlign") != null) re.setVerticalAlignment( ""+nodeAttributes.getNamedItem("vAlign").getNodeValue()); if (nodeAttributes.getNamedItem("hAlign") != null) re.setHorizontalAlignment(""+nodeAttributes.getNamedItem("hAlign").getNodeValue()); if (nodeAttributes.getNamedItem("evaluationTime") != null) re.setEvaluationTime( ""+nodeAttributes.getNamedItem("evaluationTime").getNodeValue()); if (nodeAttributes.getNamedItem("evaluationGroup") != null) re.setEvaluationGroup( ""+nodeAttributes.getNamedItem("evaluationGroup").getNodeValue()); if (nodeAttributes.getNamedItem("hyperlinkType") != null) re.setHyperlinkType(""+nodeAttributes.getNamedItem("hyperlinkType").getNodeValue()); NodeList childsOfChild = child.getChildNodes(); for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) { Node child_child = (Node)childsOfChild.item(c_count); NamedNodeMap subNodeAttributes = child_child.getAttributes(); if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) { readXMLReportElement(child_child,re); } // Element properties... else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("graphicElement")) { if (subNodeAttributes.getNamedItem("pen") != null) { re.setGraphicElementPen( ""+subNodeAttributes.getNamedItem("pen").getNodeValue()); } if (subNodeAttributes.getNamedItem("stretchType") != null) { re.setStretchType(""+subNodeAttributes.getNamedItem("stretchType").getNodeValue()); } } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("imageExpression")) { if (subNodeAttributes.getNamedItem("class") != null) { re.setImageClass(""+subNodeAttributes.getNamedItem("class").getNodeValue()); } re.setImageExpression( readPCDATA(child_child)); re.setReportDirectory(new java.io.File(this.filename).getParentFile()); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("anchorNameExpression")) { re.setAnchorNameExpression( readPCDATA(child_child) ); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkAnchorExpression")) { re.setHyperlinkAnchorExpression( readPCDATA(child_child) ); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkPageExpression")) { re.setHyperlinkPageExpression( readPCDATA(child_child) ); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("hyperlinkReferenceExpression")) { re.setHyperlinkReferenceExpression( readPCDATA(child_child) ); } } re.setPosition(re.position); re.trasform(new java.awt.Point(0,0),TransformationType.TRANSFORMATION_RESIZE_SE); if (re.getImageExpression().indexOf("(java.awt.Image)it.businesslogic.ireport.chart.IReportChartFactory.iReportChart(") >= 0) { ChartReportElement chart = new ChartReportElement( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight()); chart.setBand( re.getBand() ); chart.setHyperlinkReferenceExpression( re.getHyperlinkReferenceExpression()); chart.setHyperlinkPageExpression( re.getHyperlinkPageExpression()); chart.setHyperlinkAnchorExpression( re.getHyperlinkAnchorExpression()); chart.setHyperlinkType( re.getHyperlinkType()); chart.setBgcolor( re.getBgcolor()); chart.setEvaluationGroup( re.getEvaluationGroup()); chart.setEvaluationTime( re.getEvaluationTime()); chart.setFgcolor( re.getFgcolor()); chart.setFill( re.getFill()); chart.setGraphicElementPen( re.getGraphicElementPen()); chart.setHorizontalAlignment( re.getHorizontalAlignment()); chart.setImageClass( re.getImageClass()); chart.setImageExpression( re.getImageExpression()); chart.setName( re.getName()); chart.setPositionType( re.getPositionType()); chart.setPrintWhenExpression( re.getPrintWhenExpression() ); chart.setPrintWhenGroupChanges( re.getPrintWhenGroupChanges()); chart.setScaleImage( re.getScaleImage()); chart.setStretchType( re.getStretchType()); chart.setTransparent( re.getTransparent()); chart.setVerticalAlignment( re.getVerticalAlignment()); chart.parseExpression( chart.getImageExpression() ); re = chart; } if (re.getImageExpression().indexOf("it.businesslogic.ireport.barcode.BcImage.getBarcodeImage(") >= 0) { BarcodeReportElement bc = new BarcodeReportElement( re.getPosition().x, re.getPosition().y, re.getWidth(), re.getHeight()); bc.setBand( re.getBand() ); bc.setHyperlinkReferenceExpression( re.getHyperlinkReferenceExpression()); bc.setHyperlinkPageExpression( re.getHyperlinkPageExpression()); bc.setHyperlinkAnchorExpression( re.getHyperlinkAnchorExpression()); bc.setHyperlinkType( re.getHyperlinkType()); bc.setBgcolor( re.getBgcolor()); bc.setEvaluationGroup( re.getEvaluationGroup()); bc.setEvaluationTime( re.getEvaluationTime()); bc.setFgcolor( re.getFgcolor()); bc.setFill( re.getFill()); bc.setGraphicElementPen( re.getGraphicElementPen()); bc.setHorizontalAlignment( re.getHorizontalAlignment()); bc.setImageClass( re.getImageClass()); bc.setImageExpression( re.getImageExpression()); bc.setName( re.getName()); bc.setPositionType( re.getPositionType()); bc.setPrintWhenExpression( re.getPrintWhenExpression() ); bc.setPrintWhenGroupChanges( re.getPrintWhenGroupChanges()); bc.setScaleImage( re.getScaleImage()); bc.setStretchType( re.getStretchType()); bc.setTransparent( re.getTransparent()); bc.setVerticalAlignment( re.getVerticalAlignment()); re = bc; } elements.addElement(re); } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("rectangle")) { RectangleReportElement re = new RectangleReportElement(0,0,0,0); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); /* CompatibilitySupport.saveRoundedRectangle */ if (nodeAttributes.getNamedItem("radius") != null) re.setRadius( Integer.parseInt( (""+nodeAttributes.getNamedItem("radius").getNodeValue())) ); // Element properties... NodeList childsOfChild = child.getChildNodes(); for (int c_count=0; c_count< childsOfChild.getLength(); c_count++) { Node child_child = (Node)childsOfChild.item(c_count); NamedNodeMap subNodeAttributes = child_child.getAttributes(); if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("reportElement")) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?