Package org.xhtmlrenderer.extend

Examples of org.xhtmlrenderer.extend.ReplacedElement


     * @param elem      The element with the image reference
     * @param cssWidth  Target width of the image
     * @param cssHeight Target height of the image @return A ReplacedElement for the image; will not be null.
     */
    protected ReplacedElement replaceImage(UserAgentCallback uac, LayoutContext context, Element elem, int cssWidth, int cssHeight) {
        ReplacedElement re = null;

        // lookup in cache, or instantiate
        re = lookupImageReplacedElement(elem);
        if (re == null) {
            Image im = null;
View Full Code Here


     */
    protected ReplacedElement lookupImageReplacedElement(Element e) {
        if (imageComponents.size() == 0) {
            return null;
        }
        ReplacedElement replacedElement = (ReplacedElement) imageComponents.get(e);
        return replacedElement;
    }
View Full Code Here

     * @param cssHeight Target height for the element
     * @return A ReplacedElement to substitute for one that can't be generated.
     */
    protected ReplacedElement newIrreplaceableImageElement(int cssWidth, int cssHeight) {
        BufferedImage missingImage = null;
        ReplacedElement mre;
        try {
            // TODO: we can come up with something better; not sure if we should use Alt text, how text should size, etc.
            missingImage = ImageUtil.createCompatibleBufferedImage(cssWidth, cssHeight, BufferedImage.TYPE_INT_RGB);
            Graphics2D g = missingImage.createGraphics();
            g.setColor(Color.BLACK);
View Full Code Here

        }*/
      draw(bounds);
    }

    public void paintReplacedElement(RenderingContext c, BlockBox box) {
        ReplacedElement replaced = box.getReplacedElement();
        if (replaced instanceof SwingReplacedElement) {
            Rectangle contentBounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c);
            JComponent component = ((SwingReplacedElement)box.getReplacedElement()).getJComponent();
            RootPanel canvas = (RootPanel)c.getCanvas();
            CellRendererPane pane = canvas.getCellRendererPane();
            pane.paintComponent(_graphics, component, canvas, contentBounds.x,  contentBounds.y, contentBounds.width, contentBounds.height,true);
        } else if (replaced instanceof ImageReplacedElement) {
            Image image = ((ImageReplacedElement)replaced).getImage();
           
            Point location = replaced.getLocation();
            _graphics.drawImage(
                    image, (int)location.getX(), (int)location.getY(), null);
        }
    }
View Full Code Here

        return (XhtmlForm) _forms.get(e);
    }

    public ReplacedElement createReplacedElement(LayoutContext c, BlockBox box,
            UserAgentCallback uac, int cssWidth, int cssHeight) {
        ReplacedElement re = super.createReplacedElement(c, box, uac, cssWidth,
            cssHeight);
        if (re == null
                && c.getNamespaceHandler() instanceof XhtmlNamespaceHandler
                && !c.isPrint()) {
            XhtmlNamespaceHandler nsh = (XhtmlNamespaceHandler) c
View Full Code Here

    }

    public void remove(Element e) {
        super.remove(e);
        if (_controls != null) {
            ReplacedElement re = (ReplacedElement) _controls.get(e);
            if (re instanceof FormControlReplacementElement) {
                SWTFormControl control = ((FormControlReplacementElement) re)
                    .getControl();
                if (control != null) {
                    control.dispose();
View Full Code Here

    public void reset() {
        super.reset();
        _forms = new HashMap();
        if (_controls != null) {
            for (Iterator iter = _controls.values().iterator(); iter.hasNext();) {
                ReplacedElement re = (ReplacedElement) iter.next();
                if (re instanceof FormControlReplacementElement) {
                    SWTFormControl control = ((FormControlReplacementElement) re)
                        .getControl();
                    if (control != null) {
                        control.dispose();
View Full Code Here

     * @param cssHeight Target height of the image
     * @return A ReplacedElement for the image; will not be null.
     */
    protected ReplacedElement replaceImage(UserAgentCallback uac,
            LayoutContext context, Element elem, int cssWidth, int cssHeight) {
        ReplacedElement re = null;
        String imageSrc = context.getNamespaceHandler().getImageSourceURI(elem);
       
        if (imageSrc == null || imageSrc.length() == 0) {
            XRLog.layout(Level.WARNING, "No source provided for img element.");
            re = new ImageReplacedElement(new SWTFSImage(), cssWidth, cssHeight);
View Full Code Here

      if (e == null) {
         return null;
      } else if (context.getNamespaceHandler().isImageElement(e)) {
         final String usemapAttr = context.getNamespaceHandler().getAttributeValue(e, IMG_USEMAP_ATTR);
         if (isNotBlank(usemapAttr)) {
            final ReplacedElement re = replaceImageMap(uac, context, e, usemapAttr, cssWidth, cssHeight);
            if (context.isInteractive() && re instanceof SwingReplacedElement) {
                FSCanvas canvas = context.getCanvas();
                if (canvas instanceof JComponent) {
                    ((JComponent) canvas).add(((SwingReplacedElement) re).getJComponent());
                }
View Full Code Here

        return true;
    }

    // See SwingReplacedElementFactory#replaceImage
   protected ReplacedElement replaceImageMap(UserAgentCallback uac, LayoutContext context, Element elem, String usemapAttr, int cssWidth, int cssHeight) {
      ReplacedElement re;
      // lookup in cache, or instantiate
      re = lookupImageReplacedElement(elem, "");
      if (re == null) {
         Image im = null;
         String imageSrc = context.getNamespaceHandler().getImageSourceURI(elem);
View Full Code Here

TOP

Related Classes of org.xhtmlrenderer.extend.ReplacedElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.