Methods Summary |
---|
public void | addPageElement(java.net.URL addr)
elements.addElement(addr);
|
public void | defocusElement(java.net.URL addr)
synchronized (focusElements) {
if (focusElements.removeElement(addr)) {
focusUpdate = true;
}
}
|
public void | focusElement(java.net.URL addr)
synchronized (elements) {
if (!elements.contains(addr)) {
addPageElement(addr);
}
}
synchronized (focusElements) {
if (!focusElements.contains(addr)) {
focusElements.addElement(addr);
}
focusUpdate = true;
}
|
protected Vector | getConsumer(java.net.URL item)
ContentConsumer c;
// If the element has a consumer already,
// add it to the list
if (elementConsumers.contains(item)) {
c = (ContentConsumer)elementConsumers.get(item);
}
else {
try {
InputStream in = item.openStream();
StreamProducer sp = new StreamProducer(in);
c = makeConsumerFor(item);
c.setSource(sp);
elementConsumers.put(item, c);
}
catch (Exception e) { }
}
return c;
|
public void | loadElements()
Vector localFocus = null;
boolean done = false;
boolean changedFocus = false;
Vector consumers;
synchronized (focusElements) {
if (!focusElements.isEmpty()) {
localFocus = (Vector)focusElements.clone();
}
}
synchronized (elements) {
if (localFocus == null) {
localFocus = elements.clone();
}
}
while (!done) {
Enumeration e = localFocus.elements();
while (e.hasMoreElements()) {
URL element = (URL)e.nextElement();
ContentConsumer c = getConsumer(element);
long byteCount = elementSize(element);
// Consume a maximum of 5 percent of the entire element
// in each loop.
if (byteCount > 20) {
byteCount = byteCount / 20;
}
c.consume(byteCount);
if (isComplete(element)) {
doneElements.addElement(element);
focusElements.removeElement(element);
localFocus.removeElement(element);
}
}
synchronized (focusElements) {
if (focusUpdate) {
localFocus = focusElements.clone();
focusUpdate = false;
changedFocus = true;
}
}
if (focusElements.isEmpty()) {
// No focus elements left, so we're either done loading
// the region the user is looking at, or we've finished
// the entire page.
if (doneElements.size() == elements.size()) {
done = true;
}
else {
localFocus = elements;
}
}
}
|
public void | run()
loadElements();
|