bugId 17316

Added 4 demo pluglets
a = laa@sparc.spb.su
r = idk@eng.sun.com


git-svn-id: svn://10.0.0.236/trunk@51965 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
idk%eng.sun.com
1999-10-27 09:10:36 +00:00
parent cd137af4d4
commit ab0a4a932c
21 changed files with 1084 additions and 0 deletions

View File

@@ -0,0 +1,149 @@
import java.net.URL;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JEditorPane;
import org.mozilla.pluglet.*;
import org.mozilla.pluglet.mozilla.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.io.*;
import java.util.Vector;
import com.adobe.acrobat.Viewer;
public class PDFView implements Pluglet {
public PDFView() {
}
public PlugletInstance createPlugletInstance(String mimeType) {
try {
return new PDFViewInstance();
} catch(Exception e) {
}
return null;
}
public void initialize(PlugletManager manager) {
}
public void shutdown() {
}
}
class PDFViewInstance extends Viewer implements PlugletInstance {
JScrollPane view;
com.adobe.acrobat.Viewer acr;
Dimension defaultSize;
JPanel panel;
Frame frm;
public void displayPDF(byte[] b) {
InputStream input = (InputStream)(new ByteArrayInputStream(b));
frm.removeAll();
try {
acr = new com.adobe.acrobat.Viewer(false);
acr.setDocumentInputStream(input);
// acr.zoomTo(1.0);
acr.activate(); //WithoutBars()
acr.execMenuItem(com.adobe.acrobat.ViewerCommand.OneColumn_K);
acr.execMenuItem(com.adobe.acrobat.ViewerCommand.FitWidth_K);
} catch(Exception e) {
System.out.println("++ Error loading file.");
}
acr.setSize(new Dimension(defaultSize.width, defaultSize.height));
view.add(acr);
view.setPreferredSize(defaultSize);
frm.add(view);
frm.pack();
frm.show();
}
public PDFViewInstance() throws Exception {
}
public void initialize(PlugletInstancePeer peer) {
PlugletTagInfo2 info = (PlugletTagInfo2)peer.getTagInfo();
defaultSize = new Dimension(info.getWidth(), info.getHeight());
}
public void start() {
view = new JScrollPane();
}
public void stop() {
frm.dispose();
if(acr!=null) acr.deactivate();
}
public void destroy() {
if(acr!=null) acr.destroy();
}
public PlugletStreamListener newStream() {
PDFViewStreamListener listener = new PDFViewStreamListener();
listener.setViewer(this);
return listener;
}
public void setWindow(Frame frame) {
if (frame == null) {
return;
}
frm=frame;
frm.setSize(defaultSize);
}
public void print(PrinterJob printerJob) {
}
}
class PDFViewStreamListener implements PlugletStreamListener {
PDFViewInstance viewer;
int total = 0, length = 0, first = 0;
byte[] b, bb;
Vector v = new Vector(20, 20);
public void setViewer(PDFViewInstance view) {
viewer = view;
}
public PDFViewStreamListener() {
}
public void onStartBinding(PlugletStreamInfo streamInfo) {
bb = new byte[streamInfo.getLength()];
total = 0;
first = 0;
}
public void onDataAvailable(PlugletStreamInfo streamInfo, InputStream input,int length) {
try {
int size = input.available();
int r = 0;
b = new byte[size];
r=input.read(b);
for(int i=total;i<total+size;i++) {
bb[i]=b[i-total];
}
total+=r;
if(total>=streamInfo.getLength()) {
input.close();
viewer.displayPDF(bb);
}
} catch(Exception e) {
System.out.println(e.toString());
}
}
public void onFileAvailable(PlugletStreamInfo streamInfo, String fileName) {
}
public void onStopBinding(PlugletStreamInfo streamInfo,int status) {
}
public int getStreamType() {
return 1;
}
}

View File

@@ -0,0 +1,40 @@
MediaPlayer Pluglet Example.
================================
This directory contains the source code for Pdf Viewer pluglet example.
Pluglet is using Java "Acrobat Reader" bean.
========================================================================
Win32 Build Directions:
========================================================================
Requirements:
* built latest mozilla tree for WinNT4.0
* JDK1.3
* built Java-Implemented Plugins.
* Java "Acrobat Reader" bean installed
(http://beta1.adobe.com/acr_viewer/bean/bean.jar)
How To Build:
* add acrobat.jar to classpath
* type "nmake /f makefile.win"
How to Run:
* Follow the directions in ..\..\README
* Add acrobat.jar to classpath
* Set PLUGLET environment to the directory you have PDFViewer.jar
* Run mozilla and load page pdf.html from this directory and you will see
sample avi file. (In addition you need to download some pdf file and
name it test.pdf)

View File

@@ -0,0 +1,27 @@
#
# The contents of this file are subject to the Mozilla Public License
# Version 1.0 (the "License"); you may not use this file except in
# compliance with the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS"
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# The Initial Developer of the Original Code is Sun Microsystems,
# Inc. Portions created by Sun are Copyright (C) 1999 Sun Microsystems,
# Inc. All Rights Reserved.
.SUFFIXES: .java .class
.java.class:
$(JDKHOME)\bin\javac -classpath "../../classes;$(CLASSPATH)" $<
default: PDFView.jar
PDFView.jar: PDFView.class manifest
$(JDKHOME)\bin\jar cvfm PDFView.jar manifest *.class
clobber:
-del *.class *.jar
export: PDFView.jar
copy PDFView.jar $(PLUGLET)

View File

@@ -0,0 +1,2 @@
MIMEDescription: application/pdf::Pluglet JView
Pluglet-Class: PDFView

View File

@@ -0,0 +1,5 @@
<html>
<body>
<EMBED type="application/pdf" SRC="test.pdf" width=400 height=500>
</body>
</html>