public String getToolTipText(MouseEvent event) { String tooltip = null; JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(event); if (imageMapArea != null) { tooltip = getHyperlinkTooltip(imageMapArea.getHyperlink()); } if (tooltip == null) { tooltip = super.getToolTipText(event); } return tooltip; }
protected JRPrintImageAreaHyperlink getImageMapArea(int x, int y) { JRPrintImageAreaHyperlink image = null; if (imageAreaHyperlinks != null) { for (ListIterator it = imageAreaHyperlinks.listIterator(imageAreaHyperlinks.size()); image == null && it.hasPrevious();) { JRPrintImageAreaHyperlink area = (JRPrintImageAreaHyperlink) it.previous(); if (area.getArea().containsPoint(x, y)) { image = area; } } } return image; }
@Override public String getToolTipText(MouseEvent event) { String tooltip = null; JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(event); if (imageMapArea != null) { tooltip = getHyperlinkTooltip(imageMapArea.getHyperlink()); } if (tooltip == null) { tooltip = super.getToolTipText(event); } return tooltip; }
protected JRPrintImageAreaHyperlink getImageMapArea(int x, int y) { JRPrintImageAreaHyperlink image = null; if (imageAreaHyperlinks != null) { for (ListIterator<JRPrintImageAreaHyperlink> it = imageAreaHyperlinks.listIterator(imageAreaHyperlinks.size()); image == null && it.hasPrevious();) { JRPrintImageAreaHyperlink area = it.previous(); if (area.getArea().containsPoint(x, y)) { image = area; } } } return image; }
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)); } }
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()); } }
public void mouseClicked(MouseEvent e) { JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(e); if (imageMapArea != null) { hyperlinkClicked(imageMapArea.getHyperlink()); } }
/** * @deprecated To be removed. */ @Override public List<JRPrintImageAreaHyperlink> renderWithHyperlinks(Graphics2D grx, Rectangle2D rectangle) { try { render(grx, rectangle); } catch (JRException e) { throw new JRRuntimeException(e); } return ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, grx, rectangle); }
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"); }
/** * @deprecated To be removed. */ @Override public List<JRPrintImageAreaHyperlink> renderWithHyperlinks(Graphics2D grx, Rectangle2D rectangle) throws JRException { render(grx, rectangle); return areaHyperlinks; }
/** * Creates a SVG renderer. * * @param areaHyperlinks a list of {@link JRPrintImageAreaHyperlink area hyperlinks} */ public SimpleRenderToImageAwareDataRenderer( byte[] data, List<JRPrintImageAreaHyperlink> areaHyperlinks ) { this.data = data; this.areaHyperlinks = areaHyperlinks; }
@Override public void mouseMoved(MouseEvent e) { JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); if (imageArea != null && imageArea.getHyperlink().getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }
@Override public void mouseClicked(MouseEvent e) { JRPrintImageAreaHyperlink imageMapArea = getImageMapArea(e); if (imageMapArea != null) { hyperlinkClicked(imageMapArea.getHyperlink()); } }
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; }
public void mouseMoved(MouseEvent e) { JRPrintImageAreaHyperlink imageArea = getImageMapArea(e); if (imageArea != null && imageArea.getHyperlink().getHyperlinkTypeValue() != HyperlinkTypeEnum.NONE) { e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else { e.getComponent().setCursor(Cursor.getDefaultCursor()); } }
protected JRPrintImageAreaHyperlink getImageMapArea(MouseEvent e) { return getImageMapArea((int) (e.getX() / realZoom), (int) (e.getY() / realZoom)); }
@Override public List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks(Rectangle2D renderingArea) throws JRException { return ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, null, renderingArea); }
/** * */ public static List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks( JFreeChart chart, ChartHyperlinkProvider chartHyperlinkProvider, Graphics2D grx, Rectangle2D renderingArea )// throws JRException { List<JRPrintImageAreaHyperlink> areaHyperlinks = null; if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks()) { ChartRenderingInfo renderingInfo = new ChartRenderingInfo(); if (grx == null) { chart.createBufferedImage((int) renderingArea.getWidth(), (int) renderingArea.getHeight(), renderingInfo); } else { chart.draw(grx, renderingArea, renderingInfo); } EntityCollection entityCollection = renderingInfo.getEntityCollection(); if (entityCollection != null && entityCollection.getEntityCount() > 0) { areaHyperlinks = new ArrayList<JRPrintImageAreaHyperlink>(entityCollection.getEntityCount()); for (@SuppressWarnings("unchecked") Iterator<ChartEntity> it = entityCollection.iterator(); it.hasNext();) { ChartEntity entity = it.next(); JRPrintHyperlink printHyperlink = chartHyperlinkProvider.getEntityHyperlink(entity); if (printHyperlink != null) { JRPrintImageArea area = getImageArea(entity); JRPrintImageAreaHyperlink areaHyperlink = new JRPrintImageAreaHyperlink(); areaHyperlink.setArea(area); areaHyperlink.setHyperlink(printHyperlink); areaHyperlinks.add(areaHyperlink); } } } } return areaHyperlinks; }
@Override public Renderable getRenderable( JasperReportsContext jasperReportsContext, JFreeChart chart, ChartHyperlinkProvider chartHyperlinkProvider, Rectangle2D rectangle ) { int dpi = JRPropertiesUtil.getInstance(jasperReportsContext).getIntegerProperty(Renderable.PROPERTY_IMAGE_DPI, 72); double scale = dpi/72d; BufferedImage bi = new BufferedImage( (int) (scale * (int)rectangle.getWidth()), (int) (scale * rectangle.getHeight()), BufferedImage.TYPE_INT_ARGB ); List<JRPrintImageAreaHyperlink> areaHyperlinks = null; Graphics2D grx = bi.createGraphics(); try { grx.scale(scale, scale); if (chartHyperlinkProvider != null && chartHyperlinkProvider.hasHyperlinks()) { areaHyperlinks = ChartUtil.getImageAreaHyperlinks(chart, chartHyperlinkProvider, grx, rectangle); } else { chart.draw(grx, rectangle); } } finally { grx.dispose(); } try { return new SimpleDataRenderer(JRImageLoader.getInstance(jasperReportsContext).loadBytesFromAwtImage(bi, ImageTypeEnum.PNG), areaHyperlinks); } catch (JRException e) { throw new JRRuntimeException(e); } }
@Override public List<JRPrintImageAreaHyperlink> renderWithHyperlinks(Graphics2D grx, Rectangle2D rectangle) throws JRException { return imageMapRenderer.renderWithHyperlinks(grx, rectangle); }
@Override public List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks( Rectangle2D renderingArea) throws JRException { return imageMapRenderer.getImageAreaHyperlinks(renderingArea); }
@Override public List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks(Rectangle2D renderingArea) throws JRException { return areaHyperlinksRenderer == null ? null : areaHyperlinksRenderer.getImageAreaHyperlinks(renderingArea); }
@Override public List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks(Rectangle2D renderingArea) throws JRException { return areaHyperlinks; }
/** * */ public JRSimpleImageMapRenderer(byte[] imageData, List<JRPrintImageAreaHyperlink> areaHyperlinks) { super(imageData); this.areaHyperlinks = areaHyperlinks; }
@Override public List<JRPrintImageAreaHyperlink> getImageAreaHyperlinks(Rectangle2D renderingArea) throws JRException { return areaHyperlinksRenderer == null ? super.getImageAreaHyperlinks(renderingArea) : areaHyperlinksRenderer.getImageAreaHyperlinks(renderingArea); }
/** * */ public SimpleDataRenderer(byte[] data, List<JRPrintImageAreaHyperlink> areaHyperlinks) { this.data = data; this.areaHyperlinks = areaHyperlinks; }
protected BatikRenderer(List<JRPrintImageAreaHyperlink> areaHyperlinks) { this.areaHyperlinks = areaHyperlinks; }