report.java
来自「优秀的打印控件全源代码,类似水晶表的设计器!」· Java 代码 · 共 1,537 行 · 第 1/5 页
JAVA
1,537 行
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()); } } } 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("line")) { LineReportElement re = new LineReportElement(0,0,0,0); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); /* CompatibilitySupport.saveRoundedRectangle */ if (nodeAttributes.getNamedItem("direction") != null) re.setDirection( ""+nodeAttributes.getNamedItem("direction").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")) { 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()); } } } 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("ellipse")) { EllipseReportElement re = new EllipseReportElement(0,0,0,0); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); /* CompatibilitySupport.saveRoundedRectangle */ //if (nodeAttributes.getNamedItem("direction") != null) // re.setDirection( ""+nodeAttributes.getNamedItem("direction").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")) { 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()); } } } 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("textField")) { TextFieldReportElement re = new TextFieldReportElement(0,0,0,0); re.setIReportFont(defaultFont); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); /* CompatibilitySupport.saveRoundedRectangle */ if (nodeAttributes.getNamedItem("evaluationTime") != null) re.setEvaluationTime( ""+nodeAttributes.getNamedItem("evaluationTime").getNodeValue() ); if (nodeAttributes.getNamedItem("evaluationGroup") != null) re.setGroup( ""+nodeAttributes.getNamedItem("evaluationGroup").getNodeValue() ); if (nodeAttributes.getNamedItem("isStretchWithOverflow") != null) re.setStretchWithOverflow( nodeAttributes.getNamedItem("isStretchWithOverflow").getNodeValue().equals("true")); if (nodeAttributes.getNamedItem("isBlankWhenNull") != null) re.setBlankWhenNull(nodeAttributes.getNamedItem("isBlankWhenNull").getNodeValue().equals("true") ); if (nodeAttributes.getNamedItem("pattern") != null) re.setPattern( ""+nodeAttributes.getNamedItem("pattern").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); } 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("textFieldExpression")) { if (subNodeAttributes.getNamedItem("class") != null) { re.setClassExpression(""+subNodeAttributes.getNamedItem("class").getNodeValue()); } re.setText( readPCDATA(child_child).trim()); } 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); elements.addElement(re); } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("elementGroup")) { readBandElements( child,band); } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equals("subreport")) { SubReportElement re = new SubReportElement(0,0,0,0); re.setBand(band); NamedNodeMap nodeAttributes = child.getAttributes(); if (nodeAttributes.getNamedItem("isUsingCache") != null) re.setIsUsingCache(nodeAttributes.getNamedItem("isUsingCache").getNodeValue().equals("true") ); 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); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("parametersMapExpression")) { re.setParametersMapExpression( readPCDATA(child_child) ); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("subreportParameter")) { String name = ""; if (subNodeAttributes.getNamedItem("name") != null) { name = ""+subNodeAttributes.getNamedItem("name").getNodeValue(); } // Find expression in childs...... String expression = ""; NodeList childsOfChildOfChild = child_child.getChildNodes(); for (int c_count_2=0; c_count_2< childsOfChildOfChild.getLength(); c_count_2++) { Node child_child_child = (Node)childsOfChildOfChild.item(c_count_2); if (child_child_child.getNodeType() == Node.ELEMENT_NODE && child_child_child.getNodeName().equals("subreportParameterExpression")) { expression = readPCDATA(child_child_child); break; } } re.getSubreportParameters().addElement( new it.businesslogic.ireport.JRSubreportParameter( name, expression)); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("connectionExpression")) { re.setConnectionExpression( readPCDATA(child_child)); re.setUseConnection(true); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("dataSourceExpression")) { re.setDataSourceExpression(readPCDATA(child_child)); re.setUseConnection(false); } else if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("subreportExpression")) { re.setSubreportExpression(readPCDATA(child_child)); if (subNodeAttributes.getNamedItem("class") != null) { re.setSubreportExpressionClass(""+subNodeAttributes.getNamedItem("class").getNodeValue()); } } } re.setPosition(re.position); re.trasform(new java.awt.Point(0,0),TransformationType.TRANSFORMATION_RESIZE_SE); elements.addElement(re); } //System.out.println(""+child.getNodeName()); } } private void readXMLReportElement(Node xmlReportElement, ReportElement re) { NamedNodeMap nodeAttributes = xmlReportElement.getAttributes(); //if ( bandAttributes.getNamedItem("height") != null) b.setHeight( Integer.parseInt(bandAttributes.getNamedItem("height").getNodeValue()) ); if (nodeAttributes.getNamedItem("x") != null) re.getPosition().x = Integer.parseInt(""+nodeAttributes.getNamedItem("x").getNodeValue()); if (nodeAttributes.getNamedItem("y") != null) re.getPosition().y = Integer.parseInt(""+nodeAttributes.getNamedItem("y").getNodeValue()); if (nodeAttributes.getNamedItem("width") != null) re.setWidth( Integer.parseInt(""+nodeAttributes.getNamedItem("width").getNodeValue()) ); if (nodeAttributes.getNamedItem("height") != null) re.setHeight( Integer.parseInt(""+nodeAttributes.getNamedItem("height").getNodeValue()) ); if (nodeAttributes.getNamedItem("key") != null) re.setKey( ""+nodeAttributes.getNamedItem("key").getNodeValue() ); if (nodeAttributes.getNamedItem("stretchType") != null) re.setStretchType( ""+nodeAttributes.getNamedItem("stretchType").getNodeValue() ); if (nodeAttributes.getNamedItem("isPrintRepeatedValues") != null) re.setIsPrintRepeatedValues( (""+nodeAttributes.getNamedItem("isPrintRepeatedValues").getNodeValue()).equalsIgnoreCase("true") ); if (nodeAttributes.getNamedItem("positionType") != null) re.setPositionType( ""+nodeAttributes.getNamedItem("positionType").getNodeValue() ); else re.setPositionType( "FixRelativeToTop" ); if (nodeAttributes.getNamedItem("isPrintRepeatedValues") != null) re.setIsPrintRepeatedValues( (""+nodeAttributes.getNamedItem("isPrintRepeatedValues").getNodeValue()).equalsIgnoreCase("true") ); if (nodeAttributes.getNamedItem("isRemoveLineWhenBlank") != null) re.setIsRemoveLineWhenBlank( (""+nodeAttributes.getNamedItem("isRemoveLineWhenBlank").getNodeValue()).equalsIgnoreCase("true") ) ; if (nodeAttributes.getNamedItem("isPrintInFirstWholeBand") != null) re.setIsPrintInFirstWholeBand( (""+nodeAttributes.getNamedItem("isPrintInFirstWholeBand").getNodeValue()).equalsIgnoreCase("true") ); if (nodeAttributes.getNamedItem("isPrintWhenDetailOverflows") != null) re.setIsPrintWhenDetailOverflows( (""+nodeAttributes.getNamedItem("isPrintWhenDetailOverflows").getNodeValue()).equalsIgnoreCase("true") ); if (nodeAttributes.getNamedItem("printWhenGroupChanges") != null) re.setPrintWhenGroupChanges( ""+nodeAttributes.getNamedItem("printWhenGroupChanges").getNodeValue() ); if (nodeAttributes.getNamedItem("forecolor") != null) { String color = ""+nodeAttributes.getNamedItem("forecolor").getNodeValue(); if (color.length() == 7) { re.setFgcolor( new java.awt.Color( Integer.parseInt(color.substring(1,3),16), Integer.parseInt(color.substring(3,5),16), Integer.parseInt(color.substring(5,7),16))); } } if (nodeAttributes.getNamedItem("backcolor") != null) { String color = ""+nodeAttributes.getNamedItem("backcolor").getNodeValue(); if (color.length() == 7) { re.setBgcolor( new java.awt.Color( Integer.parseInt(color.substring(1,3),16), Integer.parseInt(color.substring(3,5),16), Integer.parseInt(color.substring(5,7),16)) ); } } if (nodeAttributes.getNamedItem("mode") != null) { re.setTransparent(""+nodeAttributes.getNamedItem("mode").getNodeValue()); } NodeList childsOfChild = xmlReportElement.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("printWhenExpression")) { re.setPrintWhenExpression( readPCDATA(child_child) ); } } } static public String readPCDATA(Node textNode) { return readPCDATA(textNode,true); } static public String readPCDATA(Node textNode, boolean trim) { NodeList list_child = textNode.getChildNodes(); for (int ck=0; ck< list_child.getLength(); ck++) { Node child_child = (Node)list_child.item(ck); if (child_child.getNodeType() == Node.CDATA_SECTION_NODE || child_child.getNodeType() == Node.TEXT_NODE) { if (trim) return ((String)child_child.getNodeValue()).trim(); return (String)child_child.getNodeValue(); } } return ""; } private void readXMLTextElement(Node xmlReportElement, TextReportElement re) { NamedNodeMap nodeAttributes = xmlReportElement.getAttributes(); if (nodeAttributes.getNamedItem("textAlignment") != null) re.setAlign(""+nodeAttributes.getNamedItem("textAlignment").getNodeValue()); if (nodeAttributes.getNamedItem("verticalAlignment") != null) re.setVerticalAlign(""+nodeAttributes.getNamedItem("verticalAlignment").getNodeValue()); if (nodeAttributes.getNamedItem("lineSpacing") != null) re.setLineSpacing( ""+nodeAttributes.getNamedItem("lineSpacing").getNodeValue()); if (nodeAttributes.getNamedItem("rotation") != null) re.setRotate(""+nodeAttributes.getNamedItem("rotation").getNodeValue()); if (nodeAttributes.getNamedItem("isStyledText") != null) re.setIsStyledText( (""+nodeAttributes.getNamedItem("isStyledText").getNodeValue()).equals("true") ); // Check for Font sub_element... NodeList childsOfChild = xmlReportElement.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("font")) { NamedNodeMap subNodeAttributes = child_child.getAttributes();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?