/** * {@inheritDoc} * * @see org.xwiki.rendering.listener.ImageListener#onImage(org.xwiki.rendering.listener.reference.ResourceReference , * boolean, java.util.Map) */ public void onImage(ResourceReference reference, boolean isFreeStandingURI, Map<String, String> parameters) { this.stack.push(new ImageBlock(reference, isFreeStandingURI, parameters)); } }
/** * {@inheritDoc} * * @see org.xwiki.rendering.block.Block#traverse(org.xwiki.rendering.listener.Listener) */ public void traverse(Listener listener) { listener.onImage(getReference(), isFreeStandingURI(), getParameters()); }
@Override public List<Block> execute(ChartMacroParameters macroParams, String content, MacroTransformationContext context) throws MacroExecutionException { // Generate the chart image in a temporary location. generateChart(macroParams, content, context); String imageLocation = this.imageWriter.getURL(new ImageId(macroParams)); String title = macroParams.getTitle(); ResourceReference reference = new ResourceReference(imageLocation, ResourceType.URL); ImageBlock imageBlock = new ImageBlock(new ResourceReference(imageLocation, ResourceType.URL), true); imageBlock.setParameter("alt", title); LinkBlock linkBlock = new LinkBlock(Collections.singletonList((Block) imageBlock), reference, true); linkBlock.setParameter("title", title); // If the macro is used standalone then we need to wrap it in a paragraph block. Block resultBlock; if (context.isInline()) { resultBlock = linkBlock; } else { resultBlock = new ParagraphBlock(Collections.singletonList((Block) linkBlock)); } return Collections.singletonList(resultBlock); }
List<ImageBlock> imgBlocks = xdom.getBlocks(new ClassBlockMatcher(ImageBlock.class), Block.Axes.DESCENDANT); for (ImageBlock imgBlock : imgBlocks) { String imageReference = imgBlock.getReference().getReference(); Block newImgBlock = new ImageBlock(urlImageReference, false, imgBlock.getParameters()); imgBlock.getParent().replaceChild(Arrays.asList(newImgBlock), imgBlock);
/** * {@inheritDoc} * * @see org.xwiki.rendering.block.AbstractBlock#clone(org.xwiki.rendering.block.BlockFilter) * @since 1.8RC2 */ @Override public ImageBlock clone(BlockFilter blockFilter) { ImageBlock clone = (ImageBlock) super.clone(blockFilter); clone.reference = getReference().clone(); return clone; } }
List<ImageBlock> imageBlocks = doc.getXdom().getChildrenByType(ImageBlock.class, true); for (ImageBlock imageBlock : imageBlocks) { String imageName = imageBlock.getImage().getName(); artifacts.put(imageName, officeDocument.getArtifacts().remove(imageName));
ImageBlock result = new ImageBlock(imageReference, false); result.setParameter("alt", formula); return result; } catch (Exception e) {
ImageBlock imageBlock = new ImageBlock(imageReference, false); imageBlock.setParameter("alt", "Picture of " + userReference.getName()); imageBlock.setParameter("title", userReference.getName()); imageBlock.setParameter("width", String.valueOf(parameters.getWidth())); imageBlock.setParameter("height", String.valueOf(parameters.getHeight()));
/** * {@inheritDoc} * * @see org.wikimodel.wem.IWemListenerInline#onImage(java.lang.String) */ public void onImage(String ref) { this.stack.push(new ImageBlock(this.imageParser.parse(ref), true)); }
/** * Create an image block if the link passed in parameter represents an image. * * @param link the link that potentially represents an image * @return an image block of the link represents an image or null if it's not an image */ private Block createImageBlock(Link link, boolean isFreeStandingURI, Map<String, String> parameters) { Block resultBlock = null; // Verify if we have an image or a link. An image is identified by an "image:" uri // The reason we get this event is because WikiModel handles links and images in the same manner. if ((link.getType() == LinkType.URI) && (link.getReference().startsWith("image:"))) { String imageLocation = link.getReference().substring("image:".length()); resultBlock = new ImageBlock(this.imageParser.parse(imageLocation), isFreeStandingURI, parameters); } return resultBlock; }
/** * {@inheritDoc} * * @see org.wikimodel.wem.IWemListenerInline#onImage(org.wikimodel.wem.WikiReference) */ public void onImage(WikiReference ref) { this.stack.push(new ImageBlock(this.imageParser.parse(ref.getLink()), false, convertParameters(ref.getParameters()))); }
Block imageBlock = new ImageBlock(imageReference, true); boxBlock.addChild(imageBlock); boxBlock.addChild(new NewLineBlock());