@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; XYDataset dataset = itemEntity.getDataset(); Comparable<?> serie = dataset.getSeriesKey(itemEntity.getSeriesIndex()); Map<Pair, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie); if (serieHyperlinks != null) { Number x = dataset.getX(itemEntity.getSeriesIndex(), itemEntity.getItem()); Number y = dataset.getY(itemEntity.getSeriesIndex(), itemEntity.getItem()); Pair<Number,Number> xyKey = new Pair<Number,Number>(x, y); printHyperlink = serieHyperlinks.get(xyKey); } } return printHyperlink; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; TimeSeriesCollection dataset = (TimeSeriesCollection) itemEntity.getDataset(); TimeSeries series = dataset.getSeries(itemEntity.getSeriesIndex()); Map<RegularTimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { RegularTimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = serieHyperlinks.get(timePeriod); } } return printHyperlink; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; TimePeriodValuesCollection dataset = (TimePeriodValuesCollection) itemEntity.getDataset(); TimePeriodValues series = dataset.getSeries(itemEntity.getSeriesIndex()); Map<TimePeriod, JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(series.getKey()); if (serieHyperlinks != null) { TimePeriod timePeriod = series.getTimePeriod(itemEntity.getItem()); printHyperlink = serieHyperlinks.get(timePeriod); } } return printHyperlink; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof CategoryItemEntity) { CategoryItemEntity itemEntity = (CategoryItemEntity) entity; Comparable<?> serie = itemEntity.getRowKey(); Map<Comparable<?>,JRPrintHyperlink> serieHyperlinks = itemHyperlinks.get(serie); if (serieHyperlinks != null) { Comparable<?> category = itemEntity.getColumnKey(); printHyperlink = serieHyperlinks.get(category); } } return printHyperlink; }
/** * */ protected boolean startHyperlink(JRPrintHyperlink link, boolean isText, boolean isOnePagePerSheet) { String href = null; String ignLnkPropName = getIgnoreHyperlinkProperty(); Boolean ignoreHyperlink = HyperlinkUtil.getIgnoreHyperlink(ignLnkPropName, link); if (ignoreHyperlink == null) { ignoreHyperlink = JRPropertiesUtil.getInstance(getJasperReportsContext()).getBooleanProperty(jasperPrint, ignLnkPropName, false); } if (!ignoreHyperlink) { href = documentBuilder.getHyperlinkURL(link, isOnePagePerSheet); } if (href != null) { writeHyperlink(link, href, isText); } return href != null; }
/** * */ protected String getHyperlinkTarget(JRPrintHyperlink link) { String target = null; switch(link.getHyperlinkTargetValue()) { case SELF : { target = "_self"; break; } case BLANK : default : { target = "_blank"; break; } } return target; }
protected String getHyperlinkTarget(JRPrintHyperlink link) { String target = null; switch(link.getHyperlinkTargetValue()) { case SELF : { target = "_self"; break; } case BLANK : default : { target = "_blank"; break; } } return target; }
/** * 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; }
protected void hyperlinkClicked(JRPrintHyperlink hyperlink) { try { JRHyperlinkListener listener = null; for(int i = 0; i < hyperlinkListeners.size(); i++) { listener = hyperlinkListeners.get(i); listener.gotoHyperlink(hyperlink); } } catch(JRException e) { if (log.isErrorEnabled()) { log.error("Hyperlink click error.", e); } JOptionPane.showMessageDialog(this, viewerContext.getBundleString("error.hyperlink")); } }
private JRPrintHyperlink getHyperlinkAt(int x, int y) { Rectangle b = reportImage.getBounds(); Rectangle ca = getClientArea(); int oX = b.width <= ca.width ? (ca.width - b.width) / 2 : -getHorizontalBar().getSelection() + MARGIN; int oY = b.height <= ca.height ? (ca.height - b.height) / 2 : -getVerticalBar().getSelection() + MARGIN; Point point = new Point((int) ((x - oX - ca.x) / zoom), (int) ((y - oY - ca.y) / zoom)); for (ListIterator<IHyperlinkContainer> it = links.listIterator(links.size()); it.hasPrevious();) { JRPrintHyperlink hyperlink = it.previous().getHyperlink(point); if (hyperlink != null) return hyperlink; } return null; }
private void initHypelinks() { links.clear(); if (page == null) return; List<JRPrintElement> elements = page.getElements(); if (elements == null) return; for (JRPrintElement element : elements) { if (element instanceof JRPrintImage) { Renderable r = ((JRPrintImage) element).getRenderable(); if (r instanceof ImageMapRenderable) { try { List<JRPrintImageAreaHyperlink> hyperlinks = ((ImageMapRenderable) r).getImageAreaHyperlinks(new java.awt.Rectangle(0, 0, element.getWidth(), element.getHeight())); if (hyperlinks != null) links.add(new ImageAreaHyperlink(element.getX(), element.getY(), hyperlinks)); } catch (JRException e) { throw new RuntimeException(e); } } } else if (element instanceof JRPrintHyperlink && !((JRPrintHyperlink) element).getHyperlinkTypeValue().equals(HyperlinkTypeEnum.NONE)) links.add(new PrintHyperlink(0, 0, element)); } }
private String getLinkToolTip(JRPrintHyperlink link) { String tTip = link.getHyperlinkTooltip(); if (tTip == null) { HyperlinkTypeEnum hType = link.getHyperlinkTypeValue(); if (hType.equals(HyperlinkTypeEnum.REFERENCE)) tTip = link.getHyperlinkReference(); else if (hType.equals(HyperlinkTypeEnum.LOCAL_ANCHOR)) { if (link.getHyperlinkAnchor() != null) tTip = "#" + link.getHyperlinkAnchor(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.LOCAL_PAGE)) { if (link.getHyperlinkPage() != null) tTip = "#page " + link.getHyperlinkPage(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.REMOTE_ANCHOR)) { if (link.getHyperlinkReference() != null) tTip = link.getHyperlinkReference(); if (currentLink.getHyperlinkAnchor() != null) tTip = "#" + currentLink.getHyperlinkAnchor(); //$NON-NLS-1$ } else if (hType.equals(HyperlinkTypeEnum.REMOTE_PAGE)) { if (link.getHyperlinkReference() != null) tTip = link.getHyperlinkReference(); if (link.getHyperlinkPage() != null) tTip = "#page " + link.getHyperlinkPage(); //$NON-NLS-1$ } } return tTip; }
protected void hyperlinkClicked(JRPrintHyperlink hyperlink) { try { JRHyperlinkListener listener = null; for(int i = 0; i < hyperlinkListeners.size(); i++) { listener = hyperlinkListeners.get(i); listener.gotoHyperlink(hyperlink); } } catch(JRException e) { if (log.isErrorEnabled()) { log.error("Hyperlink click error.", e); } JOptionPane.showMessageDialog(this, getBundleString("error.hyperlink")); } }
/** */ void hyperlinkClicked(MouseEvent evt) { JPanel link = (JPanel)evt.getSource(); JRPrintHyperlink element = (JRPrintHyperlink)linksMap.get(link); hyperlinkClicked(element); }
protected String getHyperlinkTooltip(JRPrintHyperlink hyperlink) { String toolTip; toolTip = hyperlink.getHyperlinkTooltip(); if (toolTip == null) { toolTip = getFallbackTooltip(hyperlink); } return toolTip; }
/** * Determines the provider for the chart entity based on its dataset, * and delegates the call to it. */ @Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink hyperlink = null; ChartHyperlinkProvider provider = resolveEntityProvider(entity); if (provider != null && provider.hasHyperlinks()) { hyperlink = provider.getEntityHyperlink(entity); } return hyperlink; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof PieSectionEntity) { PieSectionEntity pieEntity = (PieSectionEntity) entity; printHyperlink = sectionHyperlinks.get(pieEntity.getSectionKey()); } return printHyperlink; }
@Override public JRPrintHyperlink getEntityHyperlink(ChartEntity entity) { JRPrintHyperlink printHyperlink = null; if (hasHyperlinks() && entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; int item = itemEntity.getItem(); if (item >= 0 && item < itemHyperlinks.size()) { printHyperlink = itemHyperlinks.get(item); } } return printHyperlink; }
@Override protected void customIncrement() { if (xyzSeries != null && xyzSeries .length > 0) { for (int i = 0; i < xyzSeries.length; i++) { JRFillXyzSeries crtXyzSeries = xyzSeries[i]; Comparable<?> seriesName = crtXyzSeries.getSeries(); if (seriesName == null) { throw new JRRuntimeException( EXCEPTION_MESSAGE_KEY_SERIES_NULL_NAME, (Object[])null ); } dataset.addValue( crtXyzSeries.getSeries(), crtXyzSeries.getXValue(), crtXyzSeries.getYValue(), crtXyzSeries.getZValue() ); if (crtXyzSeries.hasItemHyperlinks()) { Map<Pair, JRPrintHyperlink> seriesLinks = itemHyperlinks.get(crtXyzSeries.getSeries()); if (seriesLinks == null) { seriesLinks = new HashMap<Pair, JRPrintHyperlink>(); itemHyperlinks.put(crtXyzSeries.getSeries(), seriesLinks); } Pair<Number,Number> xyKey = new Pair<Number,Number>(crtXyzSeries.getXValue(), crtXyzSeries.getYValue()); seriesLinks.put(xyKey, crtXyzSeries.getPrintItemHyperlink()); } } } }
@Override protected void customInitialize() { values = new LinkedHashMap<Comparable<?>, Number>(); labels = new HashMap<Comparable<?>, String>(); sectionHyperlinks = new HashMap<Comparable<?>, JRPrintHyperlink>(); // read property here because fill dataset is null on constructor ignoreDuplicatedKey = getFiller().getPropertiesUtil().getBooleanProperty( getFillDataset(), PROPERTY_IGNORE_DUPLICATED_KEY, false ); }
/** * */ protected void exportStyledTextRun( Map<AttributedCharacterIterator.Attribute, Object> attributes, String text, Locale locale, boolean startedHyperlink, boolean isIgnoreTextFormatting ) { startTextSpan(attributes, text, locale, isIgnoreTextFormatting); boolean localHyperlink = false; if (!startedHyperlink) { JRPrintHyperlink hyperlink = (JRPrintHyperlink)attributes.get(JRTextAttribute.HYPERLINK); if (hyperlink != null) { localHyperlink = startHyperlink(hyperlink, true); } } writeText(text); if (localHyperlink) { endHyperlink(true); } endTextSpan(); }
/** * */ protected void writeHyperlink(JRPrintHyperlink link, String href, boolean isText) { if(isText) { bodyWriter.write("<text:a xlink:href=\""); } else { bodyWriter.write("<draw:a xlink:type=\"simple\" xlink:href=\""); } bodyWriter.write(JRStringUtil.xmlEncode(href)); bodyWriter.write("\""); String target = getHyperlinkTarget(link);//FIXMETARGET if (target != null) { bodyWriter.write(" office:target-frame-name=\""); bodyWriter.write(target); bodyWriter.write("\""); if(target.equals("_blank")) { bodyWriter.write(" xlink:show=\"new\""); } } /* * tooltips are unavailable for the moment * if (link.getHyperlinkTooltip() != null) { bodyWriter.write(" xlink:title=\""); bodyWriter.write(JRStringUtil.xmlEncode(link.getHyperlinkTooltip())); bodyWriter.write("\""); } */ bodyWriter.write(">"); }
/** * Generates the String hyperlink target for a hyperlink instance based on its * type and on the associated hyperlink target producer. * * @param hyperlink the hyperlink instance * @return the genereated String hyperlink target * @see JRHyperlinkTargetProducer#getHyperlinkTarget(JRPrintHyperlink) */ public String produceHyperlinkTarget(JRPrintHyperlink hyperlink) { String linkTarget = hyperlink.getLinkTarget(); String target = null; if (linkTarget != null) { JRHyperlinkTargetProducer producer = getHyperlinkTargetProducer(linkTarget); if (producer != null) { target = producer.getHyperlinkTarget(hyperlink); } } return target; }
protected void writeImageMap(String imageMapName, JRPrintImage image, List<JRPrintImageAreaHyperlink> imageMapAreas) throws IOException { writer.write("<map name=\"" + imageMapName + "\">\n"); for (ListIterator<JRPrintImageAreaHyperlink> it = imageMapAreas.listIterator(imageMapAreas.size()); it.hasPrevious();) { JRPrintImageAreaHyperlink areaHyperlink = it.previous(); JRPrintHyperlink link = areaHyperlink.getHyperlink(); JRPrintImageArea area = areaHyperlink.getArea(); writer.write(" <area shape=\"" + JRPrintImageArea.getHtmlShape(area.getShape()) + "\""); writeImageAreaCoordinates(area.getCoordinates()); writeImageAreaHyperlink(link); writer.write("/>\n"); } if (image.getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { writer.write(" <area shape=\"default\""); writeImageAreaCoordinates(new int[]{0, 0, image.getWidth(), image.getHeight()});//for IE writeImageAreaHyperlink(image); writer.write("/>\n"); } writer.write("</map>\n"); }
protected void exportHyperlinkParameters(JRPrintHyperlink hyperlink) throws IOException { JRPrintHyperlinkParameters hyperlinkParameters = hyperlink.getHyperlinkParameters(); if (hyperlinkParameters != null) { for (Iterator<JRPrintHyperlinkParameter> it = hyperlinkParameters.getParameters().iterator(); it.hasNext();) { JRPrintHyperlinkParameter parameter = it.next(); exportHyperlinkParameter(parameter); } } }
/** * */ public static Boolean getIgnoreHyperlink(String propName, JRPrintHyperlink link) { if (link != null) { Boolean hyperlinkVisible = null; if (link.getHyperlinkParameters() != null) { List<JRPrintHyperlinkParameter> parameters = link.getHyperlinkParameters().getParameters(); if (parameters != null) { for (int i = 0; i < parameters.size(); i++) { JRPrintHyperlinkParameter parameter = parameters.get(i); if (propName.equals(parameter.getName())) { hyperlinkVisible = (Boolean)parameter.getValue(); break; } } } } return hyperlinkVisible; } return null; }
/** * Generates the String hyperlink for a hyperlink instance based on its * type and on the associated hyperlink producer. * * @param hyperlink the hyperlink instance * @return the genereated String hyperlink * @see JRHyperlinkProducer#getHyperlink(JRPrintHyperlink) */ public String produceHyperlink(JRPrintHyperlink hyperlink) { String linkType = hyperlink.getLinkType(); String href = null; if (linkType != null) { JRHyperlinkProducer producer = getHandler(linkType); if (producer != null) { href = producer.getHyperlink(hyperlink); } } return href; }
private void updateHyperlink(int x, int y) { JRPrintHyperlink link = getHyperlinkAt(x, y); if (link != null) { if (currentLink == null || currentLink != link) { currentLink = link; setCursor(CURSOR_HAND); setToolTipText(getLinkToolTip(link)); } } else if (currentLink != null) { currentLink = null; setCursor(null); setToolTipText(null); } }
public JRPrintHyperlink getHyperlink(Point point) { int x = point.x - originX; int y = point.y - originY; for (JRPrintImageAreaHyperlink areaHyperlink : imageAreaHyperlinks) if (areaHyperlink.getArea().containsPoint(x, y)) return areaHyperlink.getHyperlink(); return null; }
private void notifyHyperlinkListeners(JRPrintHyperlink link) { for (JRHyperlinkListener l : rViewer.getHyperlinkListeners()) { try { l.gotoHyperlink(link); } catch (JRException e) { throw new RuntimeException(e); } } }
/** */ void hyperlinkClicked(MouseEvent evt) { JPanel link = (JPanel)evt.getSource(); JRPrintHyperlink element = linksMap.get(link); hyperlinkClicked(element); }
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; }
public PieChartHyperlinkProvider(Map<Comparable<?>, JRPrintHyperlink> sectionHyperlinks) { this.sectionHyperlinks = sectionHyperlinks; }
public XYChartHyperlinkProvider(Map<Comparable<?>, Map<Pair, JRPrintHyperlink>> itemHyperlinks) { this.itemHyperlinks = itemHyperlinks; }