@Override public void visitFrame(JRFrame frame) { JRBaseFrame baseFrame = null; if (frame != null) { baseFrame = (JRBaseFrame) get(frame); if (baseFrame == null) { baseFrame = new JRBaseFrame(frame, this); } } setVisitResult(baseFrame); }
public JRBaseFrame(JRFrame frame, JRBaseObjectFactory factory) { super(frame, factory); List<JRChild> frameChildren = frame.getChildren(); if (frameChildren != null) { children = new ArrayList<JRChild>(frameChildren.size()); for (Iterator<JRChild> it = frameChildren.iterator(); it.hasNext();) { JRChild child = it.next(); children.add((JRChild)factory.getVisitResult(child)); } } lineBox = frame.getLineBox().clone(this); this.borderSplitType = frame.getBorderSplitType(); }
@Override public JRPrintElement convert(ReportConverter reportConverter, JRElement element) { JRBasePrintFrame printFrame = new JRBasePrintFrame(reportConverter.getDefaultStyleProvider()); JRFrame frame = (JRFrame)element; copyElement(reportConverter, frame, printFrame); printFrame.copyBox(frame.getLineBox()); List<JRChild> children = frame.getChildren(); if (children != null && children.size() > 0) { ConvertVisitor convertVisitor = new ConvertVisitor(reportConverter, printFrame); for(int i = 0; i < children.size(); i++) { children.get(i).visit(convertVisitor); } } return printFrame; }
/** * */ public void writeFrame( JRFrame frame, String frameName) { if(frame != null) { write( "JRDesignFrame " + frameName + " = new JRDesignFrame(jasperDesign);\n"); write(frameName + ".setBorderSplitType({0});\n", frame.getBorderSplitType()); writeReportElement( frame, frameName); writeBox( frame.getLineBox(), frameName + ".getLineBox()"); writeChildElements( frame, frameName); flush(); } }
@Override public void visitFrame(JRFrame frame) { Object fillFrame = null; // This is the only place where an object gets replaced in the factory map by something else, // and we can no longer make a precise cast when getting it. // The JRFillFrame object is replaced in the map by a JRFillFrameElements object. //JRFillFrame fillFrame = null; if (frame != null) { fillFrame = get(frame); //fillFrame = (JRFillFrame) get(frame); if (fillFrame == null) { fillFrame = new JRFillFrame(filler, frame, this); } } setVisitResult(fillFrame); }
public JRFillFrame(JRBaseFiller filler, JRFrame frame, JRFillObjectFactory factory) { super(filler, frame, factory); parentFrame = frame; lineBox = frame.getLineBox().clone(this); borderSplitType = initBorderSplitType(filler, frame); frameContainer = new JRFillFrameElements(factory); bottomTemplateFrames = new HashMap<JRStyle,JRTemplateElement>(); topTemplateFrames = new HashMap<JRStyle,JRTemplateElement>(); topBottomTemplateFrames = new HashMap<JRStyle,JRTemplateElement>(); setShrinkable(true); }
protected boolean inScope(PropertyMetadata propertyMetadata, JRElementGroup container) { if (container instanceof JRFrame) { return inScope(propertyMetadata, (JRElement) container); } List<PropertyScope> scopes = propertyMetadata.getScopes(); if (container instanceof JRBand) { return scopes.contains(PropertyScope.BAND); } if (container instanceof Cell) { return scopes.contains(PropertyScope.TABLE_CELL); } if (container instanceof JRCellContents) { return scopes.contains(PropertyScope.CROSSTAB_CELL); } return false; }
@Override protected void draw(JSSDrawVisitor drawVisitor, JRElement jrElement) { if (model == null){ drawVisitor.visitFrame((JRFrame) jrElement); return; } else if (cachedGraphics == null || model.hasChangedProperty()){ model.setChangedProperty(false); Graphics2D oldGraphics = drawVisitor.getGraphics2d(); cachedGraphics = new StackGraphics2D(oldGraphics); drawVisitor.setGraphics2D(cachedGraphics); drawVisitor.visitFrame((JRFrame) jrElement); drawVisitor.setGraphics2D(oldGraphics); } cachedGraphics.setRealDrawer(drawVisitor.getGraphics2d()); cachedGraphics.paintStack(); }
/** * */ public static JRElement getElementByKey(JRElement[] elements, String key) { JRElement element = null; if (key != null) { if (elements != null) { int i = 0; while (element == null && i < elements.length) { JRElement elem = elements[i]; if (key.equals(elem.getKey())) { element = elem; } else if (elem instanceof JRFrame) { element = ((JRFrame) elem).getElementByKey(key); } else if (elem instanceof JRCrosstab) { element = ((JRCrosstab) elem).getElementByKey(key); } i++; } } } return element; }
@Override public void visitFrame(JRFrame frame) { JRPrintElement printFrame = FrameConverter.getInstance().convert(reportConverter, frame); addElement(parentFrame, printFrame); addContour(reportConverter, parentFrame, printFrame); }
@Override public void visitFrame(JRFrame frame) { try { xmlWriter.writeFrame(frame); } catch (IOException e) { throw new JRRuntimeException(e); } }
public void writeFrame(JRFrame frame) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_frame, getNamespace()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_borderSplitType, frame.getBorderSplitType()); writeReportElement(frame); writeBox(frame.getLineBox()); writeChildElements(frame); writer.closeElement(); }
public void verifyElement(JRElement element) { if (element instanceof JRStaticText) { verifyStaticText((JRStaticText)element); } else if (element instanceof JRTextField) { verifyTextField((JRTextField)element); } else if (element instanceof JRImage) { verifyImage((JRImage)element); } else if (element instanceof JRSubreport) { verifySubreport((JRSubreport)element); } else if (element instanceof JRCrosstab) { verifyCrosstab((JRDesignCrosstab) element); } else if (element instanceof JRChart) { verifyChart((JRChart) element); } else if (element instanceof JRFrame) { verifyFrame((JRFrame) element); } else if (element instanceof JRComponentElement) { verifyComponentElement((JRComponentElement) element); } else if (element instanceof JRGenericElement) { verifyGenericElement((JRGenericElement) element); } }
private void verifyFrame(JRFrame frame) { verifyReportElement(frame); JRElement[] elements = frame.getElements(); if (elements != null && elements.length > 0) { int leftPadding = frame.getLineBox().getLeftPadding().intValue(); int rightPadding = frame.getLineBox().getRightPadding().intValue(); int avlblWidth = frame.getWidth() - leftPadding - rightPadding; for (int i = 0; i < elements.length; i++) { JRElement element = elements[i]; if (element.getX() + element.getWidth() > avlblWidth) { addBrokenRule("Element reaches outside frame width: x=" + element.getX() + ", width=" + element.getWidth() + ", available width=" + avlblWidth + ".", element); } verifyElement(element); } verifyElementsOverlap(elements); } }
private BorderSplitType initBorderSplitType(JRBaseFiller filler, JRFrame frame) { BorderSplitType splitType = frame.getBorderSplitType(); if (splitType == null) { String splitTypeProp = filler.getPropertiesUtil().getProperty(filler.getMainDataset(), PROPERTY_BORDER_SPLIT_TYPE); if (splitTypeProp != null) { splitType = BorderSplitType.byName(splitTypeProp); } } return splitType; }
private static void transformElements(JRElement[] elements, double scaleX, int offsetX, double scaleY, int offsetY) { if (elements != null) { for (int i = 0; i < elements.length; i++) { JRFillElement element = (JRFillElement) elements[i]; if (scaleX != -1d) { element.setX((int) (element.getX() * scaleX)); element.setWidth((int) (element.getWidth() * scaleX)); } if (offsetX != 0) { element.setX(element.getX() + offsetX); } if (scaleY != -1d) { element.setY((int) (element.getY() * scaleY)); element.setHeight((int) (element.getHeight() * scaleY)); } if (offsetY != 0) { element.setY(element.getY() + offsetY); } if (element instanceof JRFrame) { JRElement[] frameElements = ((JRFrame) element).getElements(); transformElements(frameElements, scaleX, offsetX, scaleY, offsetY); } } } }
private static void collectDeepElements(JRElement[] elements, List<JRFillElement> deepElementsList) { for (int i = 0; i < elements.length; i++) { JRElement element = elements[i]; deepElementsList.add((JRFillElement)element); if (element instanceof JRFillFrame) { JRFrame frame = (JRFrame) element; collectDeepElements(frame.getElements(), deepElementsList); } } }
@Override public void visitFrame(JRFrame frame) { visitor.visitFrame(frame); }
@Override public void visitFrame(JRFrame frame) { visitElement(frame); }
@Override public void visitFrame(JRFrame frame) { apiWriter.writeFrame(frame, name); }
@Override public void visitFrame(JRFrame frame) { // NOOP }
protected boolean inScope(PropertyMetadata property, JRElement element) { List<PropertyScope> scopes = property.getScopes(); if (scopes.contains(PropertyScope.ELEMENT)) { return true; } if (element instanceof JRTextElement && scopes.contains(PropertyScope.TEXT_ELEMENT)) { return true; } if (element instanceof JRImage && scopes.contains(PropertyScope.IMAGE_ELEMENT)) { return true; } if (element instanceof JRChart && scopes.contains(PropertyScope.CHART_ELEMENT)) { return true; } if (element instanceof JRCrosstab && scopes.contains(PropertyScope.CROSSTAB)) { return true; } if (element instanceof JRFrame && scopes.contains(PropertyScope.FRAME)) { return true; } if (element instanceof JRSubreport && scopes.contains(PropertyScope.SUBREPORT)) { return true; } //TODO lucianc generic element if (element instanceof JRComponentElement && scopes.contains(PropertyScope.COMPONENT)) { List<String> qualifications = property.getScopeQualifications(); if (qualifications == null || qualifications.isEmpty()) { //assuming all components return true; } JRComponentElement componentElement = (JRComponentElement) element; String qualification; if (componentElement.getComponent() instanceof Designated) { qualification = ((Designated) componentElement.getComponent()).getDesignation(); } else { ComponentKey key = componentElement.getComponentKey(); if (key == null || key.getNamespace() == null || key.getName() == null) { //key is missing qualification = null; } else { qualification = key.getNamespace() + PropertyConstants.COMPONENT_KEY_QUALIFICATION_SEPARATOR + key.getName(); } } return qualification != null && qualifications.contains(qualification); } return false; }
/** * */ public void visitFrame(JRFrame frame) { name = "[" + frame.getX() + ", " + frame.getY() + ", " + frame.getWidth() + ", " + frame.getHeight() + "]"; }
/** * */ public void visitFrame(JRFrame frame) { node = new FrameNode(jasperDesign,(JRDesignFrame)frame,doLkp); node.setIconBaseWithExtension(ICON_FRAME); }
/** * */ public void visitFrame(JRFrame frame) { collector.collect(frame); }
/** * Draw a cell painting just the border and the cell name. **/ private void paintCell(Graphics2D g, String title, int x, int y, JRCellContents contents) { if (contents == null) return; int width = contents.getWidth(); int height = contents.getHeight(); int txt_height = g.getFontMetrics().getHeight()/2; Paint oldPaint = g.getPaint(); Shape oldClip = g.getClip(); //Java2DUtils.resetClip(g); g.setPaint(CELL_LABEL_COLOR); g.drawRect(x, y, width, height); g.setPaint(oldPaint); g.setPaint(AbstractReportObjectScene.DESIGN_LINE_COLOR); AffineTransform af = g.getTransform(); AffineTransform new_af = (AffineTransform) af.clone(); AffineTransform translate = AffineTransform.getTranslateInstance( x, y); new_af.concatenate(translate); g.setTransform(new_af); JRFrame frame = getCrosstabCellFrame(new ReportConverter(getJasperDesign(),true), contents, x,y, x==0 && crosstab.getRunDirectionValue() == RunDirectionEnum.LTR, x==0 && crosstab.getRunDirectionValue() == RunDirectionEnum.RTL, false); if (frame != null && ((CrosstabObjectScene)this.getScene()).getDrawVisitor() != null) { ((CrosstabObjectScene)this.getScene()).getDrawVisitor().setGraphics2D(g); ((CrosstabObjectScene)this.getScene()).getDrawVisitor().visitFrame(frame); } g.setTransform(af); g.clipRect(x, y, width-2, height-2); // TODO: add to the visitore the code to draw a void cell.... Color cc = contents.getBackcolor() != null ? contents.getBackcolor() : Color.WHITE; cc = cc.darker(); //new Color( cc.getRed(), cc.getGreen(), cc.getBlue(), 200); g.setPaint(cc); if (IReportManager.getPreferences().getBoolean( IReportManager.PROPERTY_SHOW_CELL_NAMES, false)) { g.drawString( title, x+3, y + txt_height + 3); } g.setClip(oldClip); g.setPaint(oldPaint); }
private JRFrame getCrosstabCellFrame( ReportConverter reportConverter, JRCellContents cell, int x, int y, boolean left, boolean right, boolean top ) { JRDesignFrame frame = new JRDesignFrame(cell.getDefaultStyleProvider()); frame.setX(x); frame.setY(y); frame.setWidth(cell.getWidth()); frame.setHeight(cell.getHeight()); frame.setMode(cell.getModeValue()); frame.setBackcolor(cell.getBackcolor()); //frame.setStyle(reportConverter.resolveStyle(cell)); JRLineBox box = cell.getLineBox(); if (box != null) { frame.copyBox(box); boolean copyLeft = left && box.getLeftPen().getLineWidth().floatValue() <= 0f && box.getRightPen().getLineWidth().floatValue() > 0f; boolean copyRight = right && box.getRightPen().getLineWidth().floatValue() <= 0f && box.getLeftPen().getLineWidth().floatValue() > 0f; boolean copyTop = top && box.getTopPen().getLineWidth().floatValue() <= 0f && box.getBottomPen().getLineWidth().floatValue() > 0f; if (copyLeft) { ((JRBaseLineBox)frame.getLineBox()).copyLeftPen(box.getRightPen()); } if (copyRight) { ((JRBaseLineBox)frame.getLineBox()).copyRightPen(box.getLeftPen()); } if (copyTop) { ((JRBaseLineBox)frame.getLineBox()).copyTopPen(box.getBottomPen()); } } return frame; }
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); label.setIcon(null); if (value instanceof Node) { Node node = (Node)value; String text = node.getDisplayName(); if (node instanceof ElementNode) { text = ""; JRDesignElement element = ((ElementNode)node).getElement(); if (element instanceof JRBreak) text += "Break"; if (element instanceof JRChart) text += "Chart"; if (element instanceof JRCrosstab) text += "Crosstab"; if (element instanceof JRElementGroup) text += "Element Group"; if (element instanceof JREllipse) text += "Ellipse"; if (element instanceof JRFrame) text += "Frame"; if (element instanceof JRImage) text += "Image"; if (element instanceof JRLine) text += "Line"; if (element instanceof JRRectangle) text += "Rectangle"; if (element instanceof JRStaticText) text += "Static Text"; if (element instanceof JRSubreport) text += "Subreport"; if (element instanceof JRTextField) text += "Text Field"; JRElementGroup parent = ModelUtils.getTopElementGroup(element); if (parent != null && parent instanceof JRDesignBand) text += " in band " + ModelUtils.nameOf(((JRDesignBand)parent).getOrigin()); else if (parent != null && parent instanceof JRDesignCellContents) text += " in cell " + ModelUtils.nameOf(((JRDesignCellContents)parent).getOrigin()); text += " " + node.getDisplayName(); } label.setText(text); label.setIcon( new ImageIcon(node.getIcon(BeanInfo.ICON_COLOR_16x16))); } else if (value instanceof JRDesignExpression) { JRDesignExpression exp = (JRDesignExpression)value; label.setText(exp.getText()); label.setIcon(expressionIcon); } return label; }