Java 类net.sf.jasperreports.engine.design.JRDesignGraphicElement 实例源码

项目:jasperreports    文件:JRGraphicElementFactory.java   
@Override
public Object createObject(Attributes atts)
{
    JRDesignGraphicElement graphicElement = (JRDesignGraphicElement)digester.peek();

    StretchTypeEnum stretchType = StretchTypeEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_stretchType));
    if (stretchType != null)
    {
        if (log.isWarnEnabled())
        {
            log.warn("The 'stretchType' attribute in <graphicElement> tag is deprecated. Use the same attribut in <reportElement> tag instead.");
        }

        graphicElement.setStretchType(stretchType);
    }

    PenEnum pen = PenEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_pen));
    if (pen != null)
    {
        if (log.isWarnEnabled())
        {
            log.warn("The 'pen' attribute is deprecated. Use the <pen> tag instead.");
        }

        JRPenUtil.setLinePenFromPen(pen, graphicElement.getLinePen());
    }

    FillEnum fill = FillEnum.getByName(atts.getValue(JRXmlConstants.ATTRIBUTE_fill));
    if (fill != null)
    {
        graphicElement.setFill(fill);
    }

    return graphicElement;
}
项目:PDFReporter-Studio    文件:MGraphicElementLinePen.java   
@Override
public Object getPropertyValue(Object id) {
    // pen
    if (id.equals(LINE_PEN)) {
        JRDesignGraphicElement jrGraphicElement = (JRDesignGraphicElement) getValue();
        if (linePen == null) {
            linePen = new MLinePen(jrGraphicElement.getLinePen());
            linePen.getPropertyChangeSupport().addPropertyChangeListener(this);
        }
        return linePen;
    }
    return super.getPropertyValue(id);
}
项目:PDFReporter-Studio    文件:MGraphicElementLinePen.java   
@Override
public void trasnferProperties(JRElement target){
    super.trasnferProperties(target);
    JRDesignGraphicElement jrSourceElement = (JRDesignGraphicElement) getValue();
    JRPen jrSourceBox = (JRPen)jrSourceElement.getLinePen();

    JRDesignGraphicElement jrTargetElement = (JRDesignGraphicElement) target;
    JRPen jrTargetBox = (JRPen)jrTargetElement.getLinePen();
    if (jrSourceBox != null && jrTargetBox != null){
        jrTargetBox.setLineColor(getColorClone(jrSourceBox.getOwnLineColor()));
        jrTargetBox.setLineStyle(jrSourceBox.getOwnLineStyleValue());
        jrTargetBox.setLineWidth(jrSourceBox.getOwnLineWidth());
    }
}
项目:PDFReporter-Studio    文件:MGraphicElement.java   
@Override
public void setValue(Object value) {
    if (getValue() != null && getValue() instanceof JRDesignGraphicElement)
        ((JRBasePen) ((JRDesignGraphicElement) getValue()).getLinePen()).getEventSupport().removePropertyChangeListener(
                this);
    else if (value != null && value instanceof JRDesignGraphicElement)
        ((JRBasePen) ((JRDesignGraphicElement) value).getLinePen()).getEventSupport().addPropertyChangeListener(this);
    super.setValue(value);
}
项目:ireport-fork    文件:ElementNode.java   
public ElementNode(JasperDesign jd, JRDesignElement element, Children children, Index index, Lookup doLkp)
{
    super (children, index, new ProxyLookup( doLkp, Lookups.fixed(jd,element)));
    elemenNameVisitor = new ElementNameVisitor(jd);
    this.jd = jd;
    this.element = element;

    element.getEventSupport().addPropertyChangeListener(this);

    IReportManager.getPreferences().addPreferenceChangeListener(new WeakPreferenceChangeListener(this,IReportManager.getInstance().getPreferences()));

    if (element instanceof JRDesignGraphicElement)
    {
        JRDesignGraphicElement gele = (JRDesignGraphicElement)element;
        ((JRBasePen)gele.getLinePen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRBoxContainer)
    {
        JRBoxContainer boxcontainer = (JRBoxContainer)element;
        JRBaseLineBox baseBox = (JRBaseLineBox)boxcontainer.getLineBox();
        baseBox.getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getTopPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getBottomPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getLeftPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getRightPen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRDesignTextElement)
    {
        ((JRBaseParagraph)((JRDesignTextElement)element).getParagraph()).getEventSupport().addPropertyChangeListener(this);

    }

}
项目:PDFReporter-Studio    文件:CustomStyleResolver.java   
/**
 * When an element is imported this allow to copy inside the element the attribute of its style, if any. But
 * this dosent copy inside the element the default properties
 */
public static void copyInheritedAttributes(MGraphicElement sourceModel, JRDesignElement jrTarget){
    JRDesignElement jrSource = sourceModel.getValue();
    JRStyle style = JRStyleResolver.getBaseStyle(jrSource);
    if (style != null){
        if (jrSource.getOwnBackcolor() == null) jrTarget.setBackcolor(style.getBackcolor());
        if (jrSource.getOwnForecolor() == null) jrTarget.setForecolor(style.getForecolor());
        if (jrSource.getOwnModeValue() == null) jrTarget.setMode(style.getModeValue());

        if (sourceModel instanceof MGraphicElementLineBox){
            copyIntheritedLineBox(jrTarget, style);
        }

        if (sourceModel instanceof MGraphicElementLinePen){
            JRDesignGraphicElement jrTargetPenContainer = (JRDesignGraphicElement) jrTarget;
            inheritLinePenProeprties(jrTargetPenContainer.getLinePen(), style.getLinePen());
        }

        if (sourceModel instanceof MTextElement){
            copyInheritedTextualAttributes(jrTarget, style);
        }

        if (sourceModel instanceof MTextField){
            copyInheritedTextFieldAttributes(jrTarget, style);
        }

        if (sourceModel instanceof MImage){
            copyInheritedImageAttributes(jrTarget, style);
        }

        if (sourceModel instanceof MEllipse){
            JREllipse jrEllipse = (JREllipse) jrTarget;
            if (jrEllipse.getOwnFillValue() == null) jrEllipse.setFill(style.getFillValue());
        }

        if (sourceModel instanceof MLine){
            JRLine jrLine = (JRLine) jrTarget;
            if (jrLine.getOwnFillValue() == null) jrLine.setFill(style.getFillValue());
        }

        if (sourceModel instanceof MRectangle){
            JRRectangle jrRectangle = (JRRectangle) jrTarget;
            if (jrRectangle.getOwnFillValue() == null) jrRectangle.setFill(style.getFillValue());
            if (jrRectangle.getOwnRadius() == null) jrRectangle.setRadius(style.getRadius());
        }
    }
}
项目:ireport-fork    文件:GraphicElementPropertiesFactory.java   
/**
 * Get the GraphicElement properties...
 */
public static List<Sheet.Set> getGraphicPropertySets(JRDesignGraphicElement element, JasperDesign jd)
{
    JRDesignDataset dataset = ModelUtils.getElementDataset(element, jd);

    List<Sheet.Set> list = new ArrayList<Sheet.Set>();
    Sheet.Set propertySet = Sheet.createPropertiesSet();
    propertySet.setName("GRAPHIC_ELEMENT_PROPERTIES");
    propertySet.setDisplayName("Graphic properties");
    //propertySet.put(new PenProperty( element ));
    propertySet.put(new JRPenProperty(element.getLinePen(), element));
    propertySet.put(new FillProperty( element ));

    list.add(propertySet);

    if (element instanceof JRDesignImage)
    {
        Sheet.Set imagePropertySet = Sheet.createPropertiesSet();
        imagePropertySet.setName("IMAGE_ELEMENT_PROPERTIES");
        imagePropertySet.setDisplayName("Image properties");
        imagePropertySet.put(new ImageExpressionProperty((JRDesignImage)element, dataset));
        imagePropertySet.put(new ImageExpressionClassNameProperty((JRDesignImage)element) );
        imagePropertySet.put(new ScaleImageProperty( (JRDesignImage)element ));
        imagePropertySet.put(new HorizontalAlignmentProperty( (JRDesignImage)element ));
        imagePropertySet.put(new VerticalAlignmentProperty( (JRDesignImage)element ));
        imagePropertySet.put(new ImageUsingCacheProperty( (JRDesignImage)element ));
        imagePropertySet.put(new LazyProperty( (JRDesignImage)element ));
        imagePropertySet.put(new OnErrorTypeProperty( (JRDesignImage)element ));
        imagePropertySet.put(new ImageEvaluationTimeProperty((JRDesignImage)element, dataset));//, dataset));
        imagePropertySet.put(new EvaluationGroupProperty((JRDesignImage)element, dataset));
        list.add(imagePropertySet);
    }
    else if (element instanceof JRDesignLine)
    {
        Sheet.Set linePropertySet = Sheet.createPropertiesSet();
        linePropertySet.setName("LINE_ELEMENT_PROPERTIES");
        linePropertySet.setDisplayName("Line properties");
        linePropertySet.put(new LineDirectionProperty( (JRDesignLine)element ));
        list.add(linePropertySet);
    }
    else if (element instanceof JRDesignRectangle)
    {
        Sheet.Set rectanglePropertySet = Sheet.createPropertiesSet();
        rectanglePropertySet.setName("RECTANGLE_ELEMENT_PROPERTIES");
        rectanglePropertySet.setDisplayName("Rectangle properties");
        rectanglePropertySet.put(new RadiusProperty( (JRDesignRectangle)element ));
        list.add(rectanglePropertySet);
    }
    else if (element instanceof JRDesignEllipse)
    {
        // Nothing to do...
    }

    return list;
}
项目:ireport-fork    文件:ElementPropertiesFactory.java   
/**
 * Convenient way to get all the properties of an element.
 * Properties positions could be reordered to have a better order.
 */
public static List<Sheet.Set> getPropertySets(JRDesignElement element, JasperDesign jd)
{
    List<Sheet.Set> sets = new ArrayList<Sheet.Set>();
    sets.add( getCommonPropertySet(element, jd) );

    if (element instanceof  JRDesignGraphicElement)
    {
        sets.addAll( GraphicElementPropertiesFactory.getGraphicPropertySets((JRDesignGraphicElement)element, jd) );
    }
    if (element instanceof  JRDesignTextElement)
    {
        sets.addAll( TextElementPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof  JRDesignSubreport)
    {
        sets.addAll( SubreportPropertiesFactory.getPropertySets(element, jd) );
    }
    if (element instanceof JRDesignBreak)
    {
        sets.add( getBreakPropertySet((JRDesignBreak)element) );

    }

    if (element instanceof  JRDesignChart)
    {
        sets.addAll( ChartPropertiesFactory.getPropertySets((JRDesignChart)element, jd) );
    }



    if (element instanceof  JRBox)
    {
        sets.add( getBoxPropertySet((JRBox)element) );
    }

    if (element instanceof  JRDesignGenericElement)
    {
        sets.add(  getGenericElementPropertySet((JRDesignGenericElement)element, jd ) );
    }

    return sets;
}
项目:ireport-fork    文件:JRDesignElementWidget.java   
public JRDesignElementWidget(AbstractReportObjectScene scene, JRDesignElement element) {
    super(scene);
    this.element = element;
    setBorder(new SimpleLineBorder(this));
    updateBounds();

    try {
        if (crosstabImage == null) crosstabImage = new javax.swing.ImageIcon(getClass().getResource("/com/jaspersoft/ireport/designer/resources/crosstab-32.png"));
        if (subreportImage == null) subreportImage = new javax.swing.ImageIcon(getClass().getResource("/com/jaspersoft/ireport/designer/resources/subreport-32.png"));
        if (multiaxisImage == null) multiaxisImage = new javax.swing.ImageIcon(getClass().getResource("/com/jaspersoft/ireport/designer/resources/chartaxis-32.png"));
        if (genericElementImage == null) genericElementImage = new javax.swing.ImageIcon(getClass().getResource("/com/jaspersoft/ireport/designer/resources/genericelement-48.png"));
    } catch (Exception ex) {  }

    selectionWidget = new SelectionWidget(scene, this);
    notifyStateChanged(null, ObjectState.createNormal());
    selectionWidget.addDependency(new Dependency() {

        public void revalidateDependency() {
            //setPreferredLocation(selectionWidget.getPreferredLocation() );
            //setPreferredBounds(selectionWidget.getPreferredBounds());
            //System.out.println("Revaludated");
        }
    });

    element.getEventSupport().addPropertyChangeListener(this);

    if (element instanceof JRDesignGraphicElement)
    {
        JRDesignGraphicElement gele = (JRDesignGraphicElement)element;
        ((JRBasePen)gele.getLinePen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRBoxContainer)
    {
        JRBoxContainer boxcontainer = (JRBoxContainer)element;
        JRBaseLineBox baseBox = (JRBaseLineBox)boxcontainer.getLineBox();
        baseBox.getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getTopPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getBottomPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getLeftPen()).getEventSupport().addPropertyChangeListener(this);
        ((JRBasePen)baseBox.getRightPen()).getEventSupport().addPropertyChangeListener(this);
    }

    if (element instanceof JRDesignTextElement)
    {
        ((JRBaseParagraph)((JRDesignTextElement)element).getParagraph()).getEventSupport().addPropertyChangeListener(this);

    }
}
项目:ireport-fork    文件:FillProperty.java   
@SuppressWarnings("unchecked")
public FillProperty(JRDesignGraphicElement element)
{
    super(FillEnum.class, element);
    this.element = element;
}