Java 类net.sf.jasperreports.engine.JRHyperlink 实例源码

项目:jasperreports    文件:JRVerifier.java   
/**
 *
 */
public void verifyHyperlink(JRHyperlink hyperlink)
{
    if (hyperlink != null)
    {
        JRHyperlinkParameter[] parameters = hyperlink.getHyperlinkParameters();
        if (parameters != null)
        {
            for (int i = 0; i < parameters.length; i++)
            {
                JRHyperlinkParameter parameter = parameters[i];
                verifyHyperlinkParameter(parameter);
            }
        }
    }
}
项目:jasperreports    文件:JRFillHyperlinkHelper.java   
/**
 * Evaluate a hyperlink specification.
 * 
 * @param hyperlink the hyperlink specification
 * @param expressionEvaluator the expression evaluator to use for evaluation the hyperlink expressions
 * @param evaluationType the evaluation type, as in {@link JRFillExpressionEvaluator#evaluate(JRExpression, byte) JRFillExpressionEvaluator.evaluate(JRExpression, byte)}
 * @return a {@link JRPrintHyperlink print hyperlink} resulted from the expression evaluations.
 * @throws JRException
 */
public static JRPrintHyperlink evaluateHyperlink(JRHyperlink hyperlink,
        JRFillExpressionEvaluator expressionEvaluator,
        byte evaluationType) throws JRException
{
    if (hyperlink == null)
    {
        return null;
    }

    Boolean hyperlinkWhen = (Boolean) expressionEvaluator.evaluate(hyperlink.getHyperlinkWhenExpression(), evaluationType);
    if (hyperlink.getHyperlinkWhenExpression() != null && Boolean.TRUE.equals(hyperlinkWhen))
    {
        return null;
    }

    JRBasePrintHyperlink printHyperlink = new JRBasePrintHyperlink();
    printHyperlink.setLinkType(hyperlink.getLinkType());
    printHyperlink.setLinkTarget(hyperlink.getLinkTarget());
    printHyperlink.setHyperlinkReference((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkReferenceExpression(), evaluationType));
    printHyperlink.setHyperlinkAnchor((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkAnchorExpression(), evaluationType));
    printHyperlink.setHyperlinkPage((Integer) expressionEvaluator.evaluate(hyperlink.getHyperlinkPageExpression(), evaluationType));
    printHyperlink.setHyperlinkTooltip((String) expressionEvaluator.evaluate(hyperlink.getHyperlinkTooltipExpression(), evaluationType));
    printHyperlink.setHyperlinkParameters(evaluateHyperlinkParameters(hyperlink, expressionEvaluator, evaluationType));
    return printHyperlink;
}
项目:ireport-fork    文件:SpiderChartHyperlinkAction.java   
protected void performAction(org.openide.nodes.Node[] activatedNodes) {

        ElementNode node = (ElementNode)activatedNodes[0];
        if (node.getElement() instanceof JRDesignComponentElement &&
            ((JRDesignComponentElement)node.getElement()).getComponent() instanceof SpiderChartComponent)
        {
            SpiderChartComponent component = (SpiderChartComponent) ((JRDesignComponentElement)node.getElement()).getComponent();

            if (component.getChartSettings() == null)
            {
                component.setChartSettings(new StandardChartSettings());
            }

            JRHyperlink hyperlink = (JRHyperlink)component.getChartSettings();
            JasperDesign design = ((ElementNode)activatedNodes[0]).getJasperDesign();

            HyperlinkPanel pd = new HyperlinkPanel();
            pd.setExpressionContext(new ExpressionContext( ModelUtils.getElementDataset(((ElementNode)activatedNodes[0]).getElement(), design)) );
            pd.setHyperlink(hyperlink);
            pd.showDialog( Misc.getMainFrame() );
        }

    }
项目:openbravo-pos    文件:JRViewer300.java   
public void mouseMoved(MouseEvent e)
{
    JRPrintImageAreaHyperlink imageArea = getImageMapArea(e);
    if (imageArea != null
            && imageArea.getHyperlink().getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE)
    {
        e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
    else
    {
        e.getComponent().setCursor(Cursor.getDefaultCursor());
    }
}
项目:jasperreports    文件:JRDesignPieSeries.java   
/**
 * Sets the hyperlink specification for pie chart sections.
 * 
 * @param sectionHyperlink the hyperlink specification
 * @see #getSectionHyperlink()
 */
public void setSectionHyperlink(JRHyperlink sectionHyperlink)
{
    Object old = this.sectionHyperlink;
    this.sectionHyperlink = sectionHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_SECTION_HYPERLINK, old, this.sectionHyperlink);
}
项目:jasperreports    文件:JRDesignHighLowDataset.java   
/**
 * Sets the hyperlink specification for chart items.
 * 
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRDesignGanttSeries.java   
/**
 * Sets the hyperlink specification for chart items.
 *
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRDesignTimePeriodSeries.java   
/**
 * Sets the hyperlink specification for chart items.
 * 
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRDesignPieDataset.java   
/**
 * @deprecated Replaced by {@link #getSeries()}.
 */
public void setSectionHyperlink(JRHyperlink sectionHyperlink)
{
    if (pieSeriesList.size() == 0)
    {
        addPieSeries(new JRDesignPieSeries());
    }
    ((JRDesignPieSeries)pieSeriesList.get(0)).setSectionHyperlink(sectionHyperlink);
}
项目:jasperreports    文件:JRDesignPieDataset.java   
/**
 * 
 */
public void setOtherSectionHyperlink(JRHyperlink otherSectionHyperlink)
{
    Object old = this.otherSectionHyperlink;
    this.otherSectionHyperlink = otherSectionHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_OTHER_SECTION_HYPERLINK, old, this.otherSectionHyperlink);
}
项目:jasperreports    文件:JRDesignXyzSeries.java   
/**
 * Sets the hyperlink specification for chart items.
 * 
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRDesignXySeries.java   
/**
 * Sets the hyperlink specification for chart items.
 * 
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRDesignCategorySeries.java   
/**
 * Sets the hyperlink specification for chart items.
 * 
 * @param itemHyperlink the hyperlink specification
 * @see #getItemHyperlink()
 */
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRBaseHyperlink.java   
protected JRBaseHyperlink(JRHyperlink link, JRBaseObjectFactory factory)
{
    factory.put(link, this);

    linkType = link.getLinkType();
    linkTarget = link.getLinkTarget();
    hyperlinkReferenceExpression = factory.getExpression(link.getHyperlinkReferenceExpression());
    hyperlinkWhenExpression = factory.getExpression(link.getHyperlinkWhenExpression());
    hyperlinkAnchorExpression = factory.getExpression(link.getHyperlinkAnchorExpression());
    hyperlinkPageExpression = factory.getExpression(link.getHyperlinkPageExpression());
    hyperlinkTooltipExpression = factory.getExpression(link.getHyperlinkTooltipExpression());
    hyperlinkParameters = copyHyperlinkParameters(link, factory);
}
项目:jasperreports    文件:JRBaseHyperlink.java   
public static JRHyperlinkParameter[] copyHyperlinkParameters(JRHyperlink link, JRBaseObjectFactory factory)
{
    JRHyperlinkParameter[] linkParameters = link.getHyperlinkParameters();
    JRHyperlinkParameter[] parameters = null;
    if (linkParameters != null && linkParameters.length > 0)
    {
        parameters = new JRHyperlinkParameter[linkParameters.length];
        for (int i = 0; i < linkParameters.length; i++)
        {
            JRHyperlinkParameter parameter = linkParameters[i];
            parameters[i] = factory.getHyperlinkParameter(parameter);
        }
    }
    return parameters;
}
项目:jasperreports    文件:JRXmlWriter.java   
public void writeHyperlink(String tagName, XmlNamespace namespace, 
        JRHyperlink hyperlink) throws IOException
{
    if (hyperlink != null)
    {
        writer.startElement(tagName, namespace);

        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkType, hyperlink.getLinkType(), HyperlinkTypeEnum.NONE.getName());
        writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_hyperlinkTarget, hyperlink.getLinkTarget(), HyperlinkTargetEnum.SELF.getName());

        writeExpression(JRXmlConstants.ELEMENT_hyperlinkReferenceExpression, JASPERREPORTS_NAMESPACE,
                hyperlink.getHyperlinkReferenceExpression(), false);
        writeExpression(JRXmlConstants.ELEMENT_hyperlinkWhenExpression, JASPERREPORTS_NAMESPACE,
                hyperlink.getHyperlinkWhenExpression(), false);
        writeExpression(JRXmlConstants.ELEMENT_hyperlinkAnchorExpression, JASPERREPORTS_NAMESPACE,
                hyperlink.getHyperlinkAnchorExpression(), false);
        writeExpression(JRXmlConstants.ELEMENT_hyperlinkPageExpression, JASPERREPORTS_NAMESPACE,
                hyperlink.getHyperlinkPageExpression(), false);
        writeExpression(JRXmlConstants.ELEMENT_hyperlinkTooltipExpression, JASPERREPORTS_NAMESPACE,
                hyperlink.getHyperlinkTooltipExpression(), false);
        writeHyperlinkParameters(hyperlink.getHyperlinkParameters());

        if(isNewerVersionOrEqual(JRConstants.VERSION_3_5_1))
        {
            writer.closeElement(true);
        }
        else
        {
            writer.closeElement();
        }
    }
}
项目:jasperreports    文件:JRFillHyperlinkHelper.java   
/**
 * Evaluates a list of hyperlink parameters and produces a hyperlink parameters set
 * that can be associated with a print element.
 *  
 * @param hyperlink the hyperlink instance
 * @param expressionEvaluator the expression evaluator to use for evaluation parameter value
 * @param evaluationType the evaluation type
 * @return a print hyperlink parameters set
 * @throws JRException
 */
public static JRPrintHyperlinkParameters evaluateHyperlinkParameters(
        JRHyperlink hyperlink, 
        JRFillExpressionEvaluator expressionEvaluator,
        byte evaluationType) throws JRException
{
    JRHyperlinkParameter[] hyperlinkParameters = hyperlink.getHyperlinkParameters();
    JRPrintHyperlinkParameters printParameters;
    if (hyperlinkParameters == null)
    {
        printParameters = null;
    }
    else
    {
        printParameters = new JRPrintHyperlinkParameters();
        for (int i = 0; i < hyperlinkParameters.length; i++)
        {
            JRHyperlinkParameter hyperlinkParameter = hyperlinkParameters[i];
            JRExpression valueExpression = hyperlinkParameter.getValueExpression();
            Class<?> valueClass;
            Object value;
            if (valueExpression == null)
            {
                value = null;
                valueClass = Object.class;
            }
            else
            {
                value = expressionEvaluator.evaluate(valueExpression, evaluationType);
                valueClass = value == null ? Object.class : value.getClass();
            }

            JRPrintHyperlinkParameter printParam = new JRPrintHyperlinkParameter(hyperlinkParameter.getName(), valueClass.getName(), value);
            printParameters.addParameter(printParam);
        }
    }
    return printParameters;
}
项目:PDFReporter-Studio    文件:MHyperLink.java   
public Object getPropertyValue(Object id) {
    // pen
    JRHyperlink jrElement = (JRHyperlink) getValue();
    if (jrElement != null) {
        if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TARGET))
            return jrElement.getLinkTarget();
        if (id.equals(JRDesignHyperlink.PROPERTY_LINK_TYPE))
            return jrElement.getLinkType();
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_ANCHOR_EXPRESSION))
            return ExprUtil.getExpression(jrElement.getHyperlinkAnchorExpression());
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PAGE_EXPRESSION))
            return ExprUtil.getExpression(jrElement.getHyperlinkPageExpression());
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_REFERENCE_EXPRESSION))
            return ExprUtil.getExpression(jrElement.getHyperlinkReferenceExpression());
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_WHEN_EXPRESSION))
            return ExprUtil.getExpression(jrElement.getHyperlinkWhenExpression());
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_TOOLTIP_EXPRESSION))
            return ExprUtil.getExpression(jrElement.getHyperlinkTooltipExpression());
        if (id.equals(JRDesignHyperlink.PROPERTY_HYPERLINK_PARAMETERS)) {
            if (propertyDTO == null) {
                propertyDTO = new ParameterDTO();
                propertyDTO.setJasperDesign(getJasperDesign());
                propertyDTO.setValue(jrElement.getHyperlinkParameters());
            }
            return propertyDTO;
        }
    }
    return null;
}
项目:ireport-fork    文件:ModelUtils.java   
public static void copyHyperlink(JRHyperlink from, JRHyperlink to)
{
    if (from == null || to == null) return;
    try {

        setHyperlinkAttribute(to, "HyperlinkAnchorExpression", JRExpression.class, (from.getHyperlinkAnchorExpression() == null) ? null : from.getHyperlinkAnchorExpression().clone() );
        setHyperlinkAttribute(to, "HyperlinkPageExpression", JRExpression.class, (from.getHyperlinkPageExpression() == null) ? null : from.getHyperlinkPageExpression().clone() );
        setHyperlinkAttribute(to, "HyperlinkReferenceExpression", JRExpression.class, (from.getHyperlinkReferenceExpression() == null) ? null : from.getHyperlinkReferenceExpression().clone() );
        setHyperlinkAttribute(to, "LinkTarget", String.class, from.getLinkTarget() );
        setHyperlinkAttribute(to, "HyperlinkTarget", Byte.TYPE, from.getHyperlinkTarget() );
        setHyperlinkAttribute(to, "HyperlinkTooltipExpression", JRExpression.class, (from.getHyperlinkTooltipExpression() == null) ? null : from.getHyperlinkTooltipExpression().clone() );
        setHyperlinkAttribute(to, "LinkType", String.class, (from.getLinkType() == null) ? null : from.getLinkType() );
        setHyperlinkAttribute(to, "HyperlinkWhenExpression", JRExpression.class, (from.getHyperlinkWhenExpression()== null) ? null : from.getHyperlinkWhenExpression().clone() );



        // remove all the old params...
        JRHyperlinkParameter[] params = from.getHyperlinkParameters();
        List parameters = getHyperlinkParametersList(to);
        parameters.clear();

        if (params != null)
        {
            for (int i=0; i<params.length; ++i)
            {
                parameters.add( params[i].clone() );
            }
        }

    } catch (Throwable t)
    {
        t.printStackTrace();
    }
}
项目:ireport-fork    文件:ModelUtils.java   
/**
 * We assume the  JRHyperlink has always a way to get the parameters a list...
 * @param hl
 * @return the list of parameters
 */
private static List getHyperlinkParametersList(JRHyperlink hyperlink)
{
    if (hyperlink == null) return null;
    try {
        Method m = hyperlink.getClass().getMethod("getHyperlinkParametersList");
        return (List)m.invoke(hyperlink);
    }
    catch (Throwable t) {
        t.printStackTrace(); 
    }
    return null;
}
项目:ireport-fork    文件:ModelUtils.java   
/**
 * We assume the  JRHyperlink has always a way to get the parameters a list...
 * @param hl
 * @return the list of parameters
 */
private static void setHyperlinkAttribute(JRHyperlink hyperlink, String attribute, Class clazz, Object value)
{
    if (hyperlink == null) return;
    try {
        Method m = hyperlink.getClass().getMethod("set" + attribute, clazz);
        m.invoke(hyperlink, value);
        IReportManager.getInstance().notifyReportChange();
    }
    catch (Throwable t) { t.printStackTrace(); }
}
项目:OpenbravoPOS    文件:JRViewer300.java   
public void mouseMoved(MouseEvent e)
{
    JRPrintImageAreaHyperlink imageArea = getImageMapArea(e);
    if (imageArea != null
            && imageArea.getHyperlink().getHyperlinkType() != JRHyperlink.HYPERLINK_TYPE_NONE)
    {
        e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    }
    else
    {
        e.getComponent().setCursor(Cursor.getDefaultCursor());
    }
}
项目:openbravo-pos    文件:JRViewer300.java   
protected String getFallbackTooltip(JRPrintHyperlink hyperlink)
{
    String toolTip = null;
    switch(hyperlink.getHyperlinkType())
    {
        case JRHyperlink.HYPERLINK_TYPE_REFERENCE :
        {
            toolTip = hyperlink.getHyperlinkReference();
            break;
        }
        case JRHyperlink.HYPERLINK_TYPE_LOCAL_ANCHOR :
        {
            if (hyperlink.getHyperlinkAnchor() != null)
            {
                toolTip = "#" + hyperlink.getHyperlinkAnchor();
            }
            break;
        }
        case JRHyperlink.HYPERLINK_TYPE_LOCAL_PAGE :
        {
            if (hyperlink.getHyperlinkPage() != null)
            {
                toolTip = "#page " + hyperlink.getHyperlinkPage();
            }
            break;
        }
        case JRHyperlink.HYPERLINK_TYPE_REMOTE_ANCHOR :
        {
            toolTip = "";
            if (hyperlink.getHyperlinkReference() != null)
            {
                toolTip = toolTip + hyperlink.getHyperlinkReference();
            }
            if (hyperlink.getHyperlinkAnchor() != null)
            {
                toolTip = toolTip + "#" + hyperlink.getHyperlinkAnchor();
            }
            break;
        }
        case JRHyperlink.HYPERLINK_TYPE_REMOTE_PAGE :
        {
            toolTip = "";
            if (hyperlink.getHyperlinkReference() != null)
            {
                toolTip = toolTip + hyperlink.getHyperlinkReference();
            }
            if (hyperlink.getHyperlinkPage() != null)
            {
                toolTip = toolTip + "#page " + hyperlink.getHyperlinkPage();
            }
            break;
        }
        default :
        {
            break;
        }
    }
    return toolTip;
}
项目:jasperreports    文件:JRBasePieDataset.java   
@Override
public JRHyperlink getOtherSectionHyperlink()
{
    return otherSectionHyperlink;
}
项目:jasperreports    文件:JRBaseTimePeriodSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBaseGanttSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBasePieSeries.java   
@Override
public JRHyperlink getSectionHyperlink()
{
    return sectionHyperlink;
}
项目:jasperreports    文件:JRBaseCategorySeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBaseXyzSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBaseHighLowDataset.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBaseXySeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRBaseTimeSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRDesignHighLowDataset.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return itemHyperlink;
}
项目:jasperreports    文件:JRDesignPieDataset.java   
/**
 * @deprecated Replaced by {@link #getSeries()}.
 */
public JRHyperlink getSectionHyperlink()
{
    return pieSeriesList.size() > 0 ? (pieSeriesList.get(0)).getSectionHyperlink() : null;
}
项目:jasperreports    文件:JRDesignPieDataset.java   
@Override
public JRHyperlink getOtherSectionHyperlink()
{
    return otherSectionHyperlink;
}
项目:jasperreports    文件:JRDesignTimeSeries.java   
public void setItemHyperlink(JRHyperlink itemHyperlink)
{
    Object old = this.itemHyperlink;
    this.itemHyperlink = itemHyperlink;
    getEventSupport().firePropertyChange(PROPERTY_ITEM_HYPERLINK, old, this.itemHyperlink);
}
项目:jasperreports    文件:JRFillXyzSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return parent.getItemHyperlink();
}
项目:jasperreports    文件:JRFillTimeSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return parent.getItemHyperlink();
}
项目:jasperreports    文件:JRFillGanttSeries.java   
@Override
public JRHyperlink getItemHyperlink()
{
    return parent.getItemHyperlink();
}
项目:jasperreports    文件:JRFillPieSeries.java   
@Override
public JRHyperlink getSectionHyperlink()
{
    return parent.getSectionHyperlink();
}