EmbeddedBrowserAPI

Embedded Browser API

This document describes the suggested Embedded Browser API.

Desciption of the API and its Use Cases

  • Embedded Browser Retrieval There needs to be a way how the client will retrieve individual embedded browser component.

Suggestion: To have a browser factory which will create the browser:

BrowserFactory.createBrowser(BrowserType);

Note: There should be also created enumeration BrowserType, which will define browser type component to be created, i.e. firefox, ie, etc.

  • Embedded Browser There needs to be an interface defining the own embedded browser component.

Let name it Browser.

  • It needs to have a method to retrieve the Swing component:

public JComponent getComponent();

  • It needs a method to provide show specific URL

public void showUrl(String urlString);
Note: Here the method might be overloaded also with URL parameter.

Those should be enough for the basic browsing. Now here other methods, which provide other features.

  • To be able to pass InputStream into the browser and retrieve mutable DOM document constructed from it, to enable the editing capabilities.

public org.w3c.dom.Document read(InputStream);
This method might also be used by the other modules in order to show some html/xhtml document.

  • Methods to be able to map element to location in the component

public Point getLocation(Element);
public Rectangle\ \ getBoxRectangles(Element);

  • Methods mapping position to element

public Element getElemenAt(Point);
Note, there might be more element boxes at the same point, return all of them? public Element[[ | ]] getAllElementAt(Point); ?


Summary of the API in tables:

BrowserType enumeration
Field name Meaning of the field
FIREFOX
UNKNOWN Representing uknown browser type (not defined by this enumeration yet).


BrowserFactory class
Method name Purpose of the Method
public Browser createBrowser(BrowserType) Factory method creating browser component of specified browser type.


Browser interface
Method name Purpose of the Method
public JComponent getComponent() Provides Swing component representing the browser canvas.
public void showUrl(String) Shows the specified URL (as if typed in address field (in full browser).
public org.w3c.dom.Document read(InputStream) Reads input stream and provides DOM document constructed from it.
public Point getLocation(Element) Gets location of the element on the canvas.
public Rectangle\ \ getBoxRectangles(Element) Gets box rectangles for the specified element. This might require notion of Box to be defined.
public Element getElementAt(Point) Gets element which corresponds to certain point on canvas. This might be enhanced to provide all elements in z-order at the point.


That should be all the first, but later there might be found out more detailed needs, e.g. like need of css box notion (in order to be able better to control elements which create more and complicated box structure, e.g. table).

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo