📄 elementfactory.java
字号:
*
* @throws SAXException if there is a SAX problem.
*/
protected void startImageRef(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue("name"));
final String elementSource = atts.getValue("src");
// Log.debug("Loading: " + getContentBase() + " " + elementSource + " as image");
try
{
final boolean elementScale = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final boolean elementARatio = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), true);
final ImageElement element = ItemFactory.createImageElement(
elementName,
ParserUtil.getElementPosition(atts),
Color.white,
new URL(getContentBase(), elementSource),
elementScale,
elementARatio);
final boolean elementDynamic = ParserUtil.parseBoolean(atts.getValue("dynamic"), false);
element.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, elementDynamic);
getCurrentBand().addElement(element);
}
catch (IOException mfule)
{
throw new ParseException("Unable to create/load image", mfule, getLocator());
}
}
/**
* Create a ImageElement with an static ImageDataSource. The ImageData is read from
* the supplied URL (attribute "src") in conjunction with the contentbase defined in the
* ReportDefintionContentHandler
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startImageField(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FIELDNAME_ATT);
final boolean elementScale = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final boolean elementARatio = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), true);
final ImageElement element = ItemFactory.createImageDataRowElement(
elementName,
ParserUtil.getElementPosition(atts),
Color.white,
elementSource,
elementScale,
elementARatio);
final boolean elementDynamic = ParserUtil.parseBoolean(atts.getValue("dynamic"), false);
element.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, elementDynamic);
getCurrentBand().addElement(element);
}
/**
* Starts a drawable field.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX error.
*/
protected void startDrawableField(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FIELDNAME_ATT);
final DrawableElement element = new DrawableElement();
element.setName(elementName);
ItemFactory.setElementBounds(element, ParserUtil.getElementPosition(atts));
final DataRowDataSource drds = new DataRowDataSource(elementSource);
final DrawableFilter filter = new DrawableFilter();
filter.setDataSource(drds);
element.setDataSource(filter);
getCurrentBand().addElement(element);
}
/**
* Create a ImageElement with an static ImageDataSource. The ImageData is read from
* the supplied URL (attribute "src") in conjunction with the contentbase defined in the
* ReportDefintionContentHandler
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startImageURLField(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FIELDNAME_ATT);
final boolean elementScale = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final boolean elementARatio = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), true);
final ImageElement element = ItemFactory.createImageURLElement(
elementName,
ParserUtil.getElementPosition(atts),
Color.white,
elementSource,
elementScale,
elementARatio);
final boolean elementDynamic = ParserUtil.parseBoolean(atts.getValue("dynamic"), false);
element.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, elementDynamic);
getCurrentBand().addElement(element);
}
/**
* Create a ImageElement with an static ImageDataSource. The ImageData is read from
* the supplied URL (attribute "src") in conjunction with the contentbase defined in the
* ReportDefintionContentHandler
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startImageFunction(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FUNCTIONNAME_ATT);
final boolean elementScale = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final boolean elementARatio = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), true);
final ImageElement element = ItemFactory.createImageDataRowElement(
elementName,
ParserUtil.getElementPosition(atts),
Color.white,
elementSource,
elementScale,
elementARatio);
final boolean elementDynamic = ParserUtil.parseBoolean(atts.getValue("dynamic"), false);
element.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, elementDynamic);
getCurrentBand().addElement(element);
}
/**
* Create a ImageElement with an static ImageDataSource. The ImageData is read from
* the supplied URL (attribute "src") in conjunction with the contentbase defined in the
* ReportDefintionContentHandler
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startImageURLFunction(final Attributes atts) throws SAXException
{
final String elementName = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FUNCTIONNAME_ATT);
final boolean elementScale = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final boolean elementARatio = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), true);
final ImageElement element = ItemFactory.createImageURLElement(
elementName,
ParserUtil.getElementPosition(atts),
Color.white,
elementSource,
elementScale,
elementARatio);
final boolean elementDynamic = ParserUtil.parseBoolean(atts.getValue("dynamic"), false);
element.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, elementDynamic);
getCurrentBand().addElement(element);
}
/**
* Creates a LineShapeElement.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startLine(final Attributes atts) throws SAXException
{
final String name = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final Color c = ParserUtil.parseColor(atts.getValue(COLOR_ATT));
final float x1 = ParserUtil.parseFloat(atts.getValue("x1"), "Element x1 not specified");
final float y1 = ParserUtil.parseFloat(atts.getValue("y1"), "Element y1 not specified");
final float x2 = ParserUtil.parseFloat(atts.getValue("x2"), "Element x2 not specified");
final float y2 = ParserUtil.parseFloat(atts.getValue("y2"), "Element y2 not specified");
final Line2D line = new Line2D.Float(x1, y1, x2, y2);
final ShapeElement element = ItemFactory.createLineShapeElement(
name,
c,
ParserUtil.parseStroke(atts.getValue("weight")),
line);
getCurrentBand().addElement(element);
}
/**
* Creates a RectangleShapeElement.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startRectangle(final Attributes atts) throws SAXException
{
final String name = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final Color c = ParserUtil.parseColor(atts.getValue(COLOR_ATT));
final Rectangle2D bounds = ParserUtil.getElementPosition(atts);
final boolean shouldDraw = ParserUtil.parseBoolean(atts.getValue("draw"), false);
final boolean shouldFill = ParserUtil.parseBoolean(atts.getValue("fill"), true);
final ShapeElement element = ItemFactory.createRectangleShapeElement(
name,
c,
ParserUtil.parseStroke(atts.getValue("weight")),
bounds, shouldDraw, shouldFill);
getCurrentBand().addElement(element);
}
/**
* Creates a RectangleShapeElement.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startShapeField(final Attributes atts) throws SAXException
{
final String name = getNameGenerator().generateName(atts.getValue(NAME_ATT));
final String elementSource = atts.getValue(FIELDNAME_ATT);
final Color c = ParserUtil.parseColor(atts.getValue(COLOR_ATT));
final Rectangle2D bounds = ParserUtil.getElementPosition(atts);
final boolean shouldDraw = ParserUtil.parseBoolean(atts.getValue("draw"), false);
final boolean shouldFill = ParserUtil.parseBoolean(atts.getValue("fill"), true);
final boolean scale = ParserUtil.parseBoolean(atts.getValue("keepAspectRatio"), false);
final boolean kar = ParserUtil.parseBoolean(atts.getValue("scale"), true);
final ShapeElement element = ItemFactory.createShapeElement(
name,
bounds,
c,
ParserUtil.parseStroke(atts.getValue("weight")),
elementSource, shouldDraw, shouldFill, scale, kar);
getCurrentBand().addElement(element);
}
/**
* Creates a label element, an text element with an static datasource attached.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startLabel(final Attributes atts) throws SAXException
{
getTextElementAttributes(atts);
clearCurrentText();
}
/**
* Creates a text element. In ancient times there was a difference between string elements
* (single line) and multiline fields. This is resolved in the text element class which
* handles all cases of printing text in reports.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startMultilineField(final Attributes atts) throws SAXException
{
getDataElementAttributes(atts);
}
/**
* Creates a text element. In ancient times there was a difference between string elements
* (single line) and multiline fields. This is resolved in the text element class which
* handles all cases of printing text in reports.
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startStringField(final Attributes atts) throws SAXException
{
getDataElementAttributes(atts);
}
/**
* Creates a number element (a text element that displays a numerical value).
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startNumberField(final Attributes atts) throws SAXException
{
getDataElementAttributes(atts);
textElementFormatString = atts.getValue(FORMAT_ATT);
}
/**
* Creates a date element (a text element that displays a date value).
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startDateField(final Attributes atts) throws SAXException
{
getDataElementAttributes(atts);
textElementFormatString = atts.getValue(FORMAT_ATT);
}
/**
* Begins processing a number function element (which is a text element).
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startNumberFunction(final Attributes atts) throws SAXException
{
getFunctionElementAttributes(atts);
textElementFormatString = atts.getValue(FORMAT_ATT);
}
/**
* Begins processing a date function element (which is a text element).
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startDateFunction(final Attributes atts) throws SAXException
{
getFunctionElementAttributes(atts);
textElementFormatString = atts.getValue(FORMAT_ATT);
}
/**
* Begins processing a string function element (which is a text element).
*
* @param atts the attributes.
*
* @throws SAXException if there is a SAX problem.
*/
protected void startStringFunction(final Attributes atts) throws SAXException
{
getFunctionElementAttributes(atts);
}
/**
* Ends a label tag, sets the static text for the label which was build during the
* parsing. The label is added to the current band.
*
* @throws SAXException if there is a SAX problem.
*/
protected void endLabel() throws SAXException
{
final TextElement te = ItemFactory.createLabelElement(
textElementName,
textElementBounds,
textElementColor,
textElementAlignment,
textElementVerticalAlignment,
null,
getCurrentText());
te.getStyle().setBooleanStyleProperty
(ElementStyleSheet.DYNAMIC_HEIGHT, textElementDynamic);
FontFactory.applyFontInformation(te.getStyle(), textElementFont);
clearCurrentText();
getCurrentBand().addElement(te);
}
/**
* Ends the line element and adds it to the current band.
*
* @throws SAXException if there is a SAX problem.
*/
protected void endLine() throws SAXException
{
}
/**
* Ends the shape element.
*
* @throws SAXException if there is a SAX problem.
*/
protected void endShapeField() throws SAXException
{
}
/**
* Ends the rectangle shape element and adds it to the current band.
*
* @throws SAXException if there is a SAX problem.
*/
protected void endRectangle() throws SAXException
{
}
/**
* Ends the image element and adds it to the current band.
*
* @throws SAXException if there is a SAX problem.
*/
protected void endImageField() throws SAXException
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -