You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by jm...@apache.org on 2013/10/08 16:03:39 UTC
[24/62] [abbrv] [partial] Merged Apache Flex 4.9.0 release branch
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterFileSource.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterFileSource.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterFileSource.java
deleted file mode 100644
index 96109f3..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterFileSource.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-
- Copyright 2001,2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.rasterizer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-
-/**
- * Describes a file source for the <tt>SVGConverter</tt>
- *
- * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: SVGConverterFileSource.java,v 1.5 2004/08/18 07:12:26 vhardy Exp $
- */
-public class SVGConverterFileSource implements SVGConverterSource {
- File file;
- String ref;
-
- public SVGConverterFileSource(File file){
- this.file = file;
- }
-
- public SVGConverterFileSource(File file, String ref){
- this.file = file;
- this.ref = ref;
- }
-
- public String getName(){
- String name = file.getName();
- if (ref != null && !"".equals(ref)){
- name += "#" + ref;
- }
- return name;
- }
-
- public File getFile(){
- return file;
- }
-
- public String toString(){
- return getName();
- }
-
- public String getURI(){
- try{
- String uri = file.toURL().toString();
- if (ref != null && !"".equals(ref)){
- uri += "#" + ref;
- }
- return uri;
- } catch(MalformedURLException e){
- throw new Error();
- }
- }
-
- public boolean equals(Object o){
- if (o == null || !(o instanceof SVGConverterFileSource)){
- return false;
- }
-
- return file.equals(((SVGConverterFileSource)o).file);
- }
-
- public InputStream openStream() throws FileNotFoundException{
- return new FileInputStream(file);
- }
-
- public boolean isSameAs(String srcStr){
- if (file.toString().equals(srcStr)){
- return true;
- }
-
- return false;
- }
-
- public boolean isReadable(){
- return file.canRead();
- }
-}
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterSource.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterSource.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterSource.java
deleted file mode 100644
index f53db49..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterSource.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-
- Copyright 2001,2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.rasterizer;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Interface used to handle both Files and URLs in the
- * <tt>SVGConverter</tt>
- *
- * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: SVGConverterSource.java,v 1.5 2004/08/18 07:12:26 vhardy Exp $
- */
-public interface SVGConverterSource {
- /**
- * Returns the name of the source. That would be the
- * name for a File or URL
- */
- public String getName();
-
- /**
- * Gets a <tt>TranscoderInput</tt> for that source
- */
- public InputStream openStream() throws IOException;
-
- /**
- * Checks if same as source described by srcStr
- */
- public boolean isSameAs(String srcStr);
-
- /**
- * Checks if source can be read
- */
- public boolean isReadable();
-
- /**
- * Returns a URI string corresponding to this source
- */
- public String getURI();
-}
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterURLSource.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterURLSource.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterURLSource.java
deleted file mode 100644
index fd3f296..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/rasterizer/SVGConverterURLSource.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-
- Copyright 1999-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.apache.flex.forks.batik.apps.rasterizer;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.flex.forks.batik.util.ParsedURL;
-
-/*
- * @author <a href="mailto:vhardy@apache.org">Vincent Hardy</a>
- * @version $Id: SVGConverterURLSource.java,v 1.6 2004/10/30 18:38:04 deweese Exp $
- */
-public class SVGConverterURLSource implements SVGConverterSource {
- /**
- * SVG file extension
- */
- protected static final String SVG_EXTENSION = ".svg";
- protected static final String SVGZ_EXTENSION = ".svgz";
-
- //
- // Reported when the URL for one of the sources is
- // invalid. This will happen if the URL is malformed or
- // if the URL file does not end with the ".svg" extension.
- // This is needed to be able to create a file name for
- // the ouptut automatically.
- //
- public static final String ERROR_INVALID_URL
- = "SVGConverterURLSource.error.invalid.url";
-
- ParsedURL purl;
- String name;
-
- public SVGConverterURLSource(String url) throws SVGConverterException{
- this.purl = new ParsedURL(url);
-
- // Get the path portion
- String path = this.purl.getPath();
- if (path == null ||
- !(path.toLowerCase().endsWith(SVG_EXTENSION) ||
- path.toLowerCase().endsWith(SVGZ_EXTENSION))){
- throw new SVGConverterException(ERROR_INVALID_URL,
- new Object[]{url});
- }
-
- int n = path.lastIndexOf("/");
- if (n != -1){
- // The following is safe because we know there is at least ".svg"
- // after the slash.
- path = path.substring(n+1);
- }
-
- name = path;
-
- //
- // The following will force creation of different output file names
- // for urls with references (e.g., anne.svg#svgView(viewBox(0,0,4,5)))
- //
- String ref = this.purl.getRef();
- if (ref != null && (ref.length()!=0)) {
- name += "" + ref.hashCode();
- }
- }
-
- public String toString(){
- return purl.toString();
- }
-
- public String getURI(){
- return toString();
- }
-
- public boolean equals(Object o){
- if (o == null || !(o instanceof SVGConverterURLSource)){
- return false;
- }
-
- return purl.equals(((SVGConverterURLSource)o).purl);
- }
-
- public InputStream openStream() throws IOException {
- return purl.openStream();
- }
-
- public boolean isSameAs(String srcStr){
- return toString().equals(srcStr);
- }
-
- public boolean isReadable(){
- return true;
- }
-
- public String getName(){
- return name;
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/slideshow/Main.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/slideshow/Main.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/slideshow/Main.java
deleted file mode 100644
index 426f638..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/slideshow/Main.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
-
- Copyright 1999-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-*/
-
-package org.apache.flex.forks.batik.apps.slideshow;
-
-import java.awt.Color;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Vector;
-
-import javax.swing.JComponent;
-import javax.swing.JWindow;
-
-import org.apache.flex.forks.batik.bridge.BridgeContext;
-import org.apache.flex.forks.batik.bridge.DocumentLoader;
-import org.apache.flex.forks.batik.bridge.GVTBuilder;
-import org.apache.flex.forks.batik.bridge.UserAgent;
-import org.apache.flex.forks.batik.bridge.UserAgentAdapter;
-import org.apache.flex.forks.batik.bridge.ViewBox;
-import org.apache.flex.forks.batik.gvt.GraphicsNode;
-import org.apache.flex.forks.batik.gvt.renderer.StaticRenderer;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.flex.forks.dom.svg.SVGDocument;
-
-public class Main extends JComponent {
-
- StaticRenderer renderer;
- UserAgent userAgent;
- DocumentLoader loader;
- BridgeContext ctx;
-
- BufferedImage image;
- BufferedImage display;
- File [] files;
-
- static int duration = 3000;
- static int frameDelay = duration+7000;
-
- boolean done = false;
-
- public Main(File []files, Dimension size) {
- setBackground(Color.black);
- this.files = files;
- renderer = new StaticRenderer();
- userAgent = new UserAgentAdapter();
- loader = new DocumentLoader(userAgent);
- ctx = new BridgeContext(userAgent, loader);
-
- if (size == null) {
- size = Toolkit.getDefaultToolkit().getScreenSize();
- }
-
- setPreferredSize(size);
- setDoubleBuffered(false);
- addMouseListener(new MouseAdapter() {
- public void mouseClicked(MouseEvent me) {
- if (done)
- System.exit(0);
- else
- togglePause();
- }
- });
-
- size.width += 2;
- size.height += 2;
- display = new BufferedImage(size.width, size.height,
- BufferedImage.TYPE_INT_BGR);
-
- Thread t = new RenderThread();
- t.start();
-
- JWindow w = new JWindow();
- w.setBackground(Color.black);
- w.getContentPane().setBackground(Color.black);
- w.getContentPane().add(this);
- w.pack();
- w.setLocation(new Point(-1, -1));
- w.setVisible(true);
- }
-
- class RenderThread extends Thread {
- public void run() {
- renderer.setDoubleBuffered(true);
- for (int i=0; i<files.length; i++) {
- GraphicsNode gvtRoot = null;
- GVTBuilder builder = new GVTBuilder();
-
- try {
- System.out.println("Reading: " + files[i]);
- Document svgDoc = loader.loadDocument
- (files[i].toURL().toString());
- System.out.println("Building: " + files[i]);
- gvtRoot = builder.build(ctx, svgDoc);
- System.out.println("Rendering: " + files[i]);
- renderer.setTree(gvtRoot);
-
- Element elt = ((SVGDocument)svgDoc).getRootElement();
- renderer.setTransform
- (ViewBox.getViewTransform
- (null, elt, display.getWidth(), display.getHeight()));
-
- renderer.updateOffScreen(display.getWidth(),
- display.getHeight());
-
- Rectangle r = new Rectangle(0, 0,
- display.getWidth(),
- display.getHeight());
- renderer.repaint(r);
- System.out.println("Painting: " + files[i]);
- image = renderer.getOffScreen();
- setTransition(image);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- if (transitionThread != null) {
- try {
- transitionThread.join();
- } catch (InterruptedException ie) { }
- done = true;
- setCursor(new Cursor(Cursor.WAIT_CURSOR));
- }
- }
- }
-
- Thread transitionThread = null;
-
- public void setTransition(BufferedImage newImg) {
- synchronized (this) {
- while (transitionThread != null) {
- try {
- wait();
- } catch (InterruptedException ie) { }
- }
- transitionThread = new TransitionThread(newImg);
- transitionThread.start();
- }
- }
-
-
- long startLastTransition=0;
-
- boolean paused = false;
-
- public void togglePause() {
- synchronized(this) {
- paused = !paused;
- Cursor c;
- if (paused) {
- c = new Cursor(Cursor.WAIT_CURSOR);
- } else {
- c = new Cursor(Cursor.DEFAULT_CURSOR);
- if (transitionThread != null) {
- synchronized (transitionThread) {
- transitionThread.notifyAll();
- }
- }
- }
- setCursor(c);
- }
- }
-
- class TransitionThread extends Thread {
- BufferedImage src;
- int blockw = 75;
- int blockh = 75;
-
- public TransitionThread(BufferedImage bi) {
- src = bi;
- }
-
- public void run() {
- int xblocks = (display.getWidth()+blockw-1)/blockw;
- int yblocks = (display.getHeight()+blockh-1)/blockh;
- int nblocks = xblocks*yblocks;
-
- int tblock = duration/nblocks;
-
- Point [] rects = new Point[nblocks];
- for (int y=0; y<yblocks; y++)
- for (int x=0; x<xblocks; x++)
- rects[y*xblocks+x] = new Point(x, y);
-
- Graphics2D g2d = display.createGraphics();
- g2d.setColor(new Color(0,0,0));
-
- long currTrans = System.currentTimeMillis();
- while ((currTrans-startLastTransition) < frameDelay) {
- try {
- long stime = frameDelay-(currTrans-startLastTransition);
- if (stime > 500) {
- System.gc();
- currTrans = System.currentTimeMillis();
- stime = frameDelay-(currTrans-startLastTransition);
- }
- if (stime > 0) sleep(stime);
- } catch (InterruptedException ie) { }
- currTrans = System.currentTimeMillis();
- }
-
- synchronized(this) {
- while (paused) {
- try {
- wait();
- } catch (InterruptedException ie) { }
- }
- }
-
- long last = startLastTransition = System.currentTimeMillis();
-
- for (int i=0; i<rects.length; i++) {
- int idx = (int)(Math.random()*(rects.length-i));
- Point pt = rects[idx];
- for (int j=idx+1; j<rects.length-i;j++)
- rects[j-1] = rects[j];
- int x=pt.x*blockw, y=pt.y*blockh;
- int w=blockw, h = blockh;
- if (x+w > src.getWidth()) w = src.getWidth()-x;
- if (y+h > src.getHeight()) h = src.getHeight()-y;
-
- synchronized (display) {
- g2d.fillRect(x, y, w, h);
- BufferedImage sub;
-
- sub = src.getSubimage(x, y, w, h);
- g2d.drawImage(sub, null, x, y);
- }
-
- repaint(x, y, w, h);
- long current = System.currentTimeMillis();
- try {
- long dt = current-last;
- if (dt < tblock)
- sleep(tblock-dt);
- } catch (InterruptedException ie) { }
- last = current;
- }
-
- synchronized (Main.this) {
- transitionThread = null;
- Main.this.notifyAll();
- }
- }
- }
-
- public void paint(Graphics g) {
- Graphics2D g2d = (Graphics2D)g;
- if (display == null) return;
- // System.out.println("Drawing Image: " + display);
- g2d.drawImage(display, null, 0, 0);
- }
-
- public static void readFileList(String file, Vector fileVec) {
- BufferedReader br;
- try {
- br = new BufferedReader(new FileReader(file));
- } catch(FileNotFoundException fnfe) {
- System.err.println("Unable to open file-list: " + file);
- return;
- }
- try {
- URL flURL = new File(file).toURL();
- String line;
- while ((line = br.readLine()) != null) {
- String str = line;
- int idx = str.indexOf('#');
- if (idx != -1)
- str = str.substring(0, idx);
- str.trim();
- if (str.length() == 0)
- continue;
- try {
- URL imgURL = new URL(flURL, str);
- fileVec.add(imgURL.getFile());
- } catch (MalformedURLException mue) {
- System.err.println("Can't make sense of line:\n " + line);
- }
- }
- } catch (IOException ioe) {
- System.err.println("Error while reading file-list: " + file);
- }
- }
-
- public static void main(String []args) {
-
- Vector fileVec = new Vector();
-
- Dimension d = null;
-
- if (args.length == 0) {
- showUsage();
- return;
- }
-
- for (int i=0; i<args.length; i++) {
- if ((args[i].equals("-h")) ||
- (args[i].equals("-help")) ||
- (args[i].equals("--help"))){
- showUsage();
- return;
- } else if (args[i].equals("--")) {
- i++;
- while(i < args.length) {
- fileVec.add(args[i++]);
- }
- break;
- } else if ((args[i].equals("-fl"))||
- (args[i].equals("--file-list"))) {
- if (i+1 == args.length) {
- System.err.println
- ("Must provide name of file list file after " +
- args[i]);
- break;
- }
- readFileList(args[i+1], fileVec);
- i++;
- } else if ((args[i].equals("-ft"))||
- (args[i].equals("--frame-time"))) {
- if (i+1 == args.length) {
- System.err.println
- ("Must provide time in millis after " + args[i]);
- break;
- }
- try {
- frameDelay = Integer.decode(args[i+1]).intValue();
- i++;
- } catch (NumberFormatException nfe) {
- System.err.println
- ("Can't parse frame time: " + args[i+1]);
- }
- } else if ((args[i].equals("-tt"))||
- (args[i].equals("--transition-time"))) {
- if (i+1 == args.length) {
- System.err.println
- ("Must provide time in millis after " + args[i]);
- break;
- }
- try {
- duration = Integer.decode(args[i+1]).intValue();
- i++;
- } catch (NumberFormatException nfe) {
- System.err.println
- ("Can't parse transition time: " + args[i+1]);
- }
- } else if ((args[i].equals("-ws"))||
- (args[i].equals("--window-size"))) {
-
- if (i+1 == args.length) {
- System.err.println
- ("Must provide window size [w,h] after " + args[i]);
- break;
- }
- try {
- int idx = args[i+1].indexOf(',');
- int w, h;
- if (idx == -1)
- w = h = Integer.decode(args[i+1]).intValue();
- else {
- String wStr = args[i+1].substring(0,idx);
- String hStr = args[i+1].substring(idx+1);
- w = Integer.decode(wStr).intValue();
- h = Integer.decode(hStr).intValue();
- }
- d = new Dimension(w, h);
- i++;
- } catch (NumberFormatException nfe) {
- System.err.println
- ("Can't parse window size: " + args[i+1]);
- }
- } else
- fileVec.add(args[i]);
- }
-
- File [] files = new File[fileVec.size()];
-
-
- for (int i=0; i<fileVec.size(); i++) {
- try {
- files[i] = new File((String)fileVec.get(i));
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- new Main(files, d);
- }
-
- public static void showUsage() {
- System.out.println
-("Options:\n" +
- " -- : Remaining args are file names\n" +
- " -fl <file>\n" +
- " --file-list <file> : file contains list of images to\n" +
- " show one per line\n" +
- " -ws <width>[,<height>]\n" +
- " -window-size <width>[,<height>] : Set the size of slideshow window\n" +
- " defaults to full screen\n" +
- " -ft <int>\n" +
- " --frame-time <int> : Amount of time in millisecs to\n" +
- " show each frame.\n" +
- " Includes transition time.\n" +
- " -tt <int>\n" +
- " --transition-time <int> : Amount of time in millisecs to\n" +
- " transition between frames.\n" +
- " <file> : SVG file to display");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/AboutDialog.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/AboutDialog.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/AboutDialog.java
deleted file mode 100644
index 62d96d7..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/AboutDialog.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-
- Copyright 2001-2004 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.svgbrowser;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Frame;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.net.URL;
-
-import javax.swing.BorderFactory;
-import javax.swing.ImageIcon;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextArea;
-import javax.swing.JWindow;
-import javax.swing.SwingConstants;
-import javax.swing.border.BevelBorder;
-
-import org.apache.flex.forks.batik.Version;
-
-/**
- * A dialog showing the revision of the Batik viewer as well
- * as the list of contributors.
- * The dialog can be dismissed by click or by escaping.
- *
- * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
- * @version $Id: AboutDialog.java,v 1.14 2004/08/18 07:12:26 vhardy Exp $
- */
-public class AboutDialog extends JWindow {
-
- public static final String ICON_BATIK_SPLASH
- = "AboutDialog.icon.batik.splash";
-
- public static final String ICON_APACHE_LOGO
- = "AboutDialog.icon.apache.logo";
-
- public static final String LABEL_APACHE_BATIK_PROJECT
- = "AboutDialog.label.apache.batik.project";
-
- public static final String LABEL_CONTRIBUTORS
- = "AboutDialog.label.contributors";
-
- /**
- * Default constructor
- */
- public AboutDialog(){
- super();
- buildGUI();
- }
-
- public AboutDialog(Frame owner){
- super(owner);
- buildGUI();
-
- addKeyListener(new KeyAdapter(){
- public void keyPressed(KeyEvent e){
- if(e.getKeyCode() == KeyEvent.VK_ESCAPE){
- setVisible(false);
- dispose();
- }
- }
- });
-
- addMouseListener(new MouseAdapter(){
- public void mousePressed(MouseEvent e){
- setVisible(false);
- dispose();
- }
- });
- }
-
- public void setLocationRelativeTo(Frame f) {
- Dimension invokerSize = f.getSize();
- Point loc = f.getLocation();
- Point invokerScreenLocation = new Point(loc.x, loc.y);
-
- Rectangle bounds = getBounds();
- int dx = invokerScreenLocation.x+((invokerSize.width-bounds.width)/2);
- int dy = invokerScreenLocation.y+((invokerSize.height - bounds.height)/2);
- Dimension screenSize = getToolkit().getScreenSize();
-
- if (dy+bounds.height>screenSize.height) {
- dy = screenSize.height-bounds.height;
- dx = invokerScreenLocation.x<(screenSize.width>>1) ? invokerScreenLocation.x+invokerSize.width :
- invokerScreenLocation.x-bounds.width;
- }
- if (dx+bounds.width>screenSize.width) {
- dx = screenSize.width-bounds.width;
- }
-
- if (dx<0) dx = 0;
- if (dy<0) dy = 0;
- setLocation(dx, dy);
- }
-
- /**
- * Populates this window
- */
- protected void buildGUI(){
- JPanel panel = new JPanel(new BorderLayout(5, 5));
- panel.setBackground(Color.white);
-
- ClassLoader cl = this.getClass().getClassLoader();
-
- //
- // Top is made of the Apache feather, the
- // name of the project and URL
- //
- URL url = cl.getResource(Resources.getString(ICON_APACHE_LOGO));
- JLabel l = new JLabel(Resources.getString(LABEL_APACHE_BATIK_PROJECT),
- new ImageIcon(url),
- SwingConstants.LEFT);
- panel.add(BorderLayout.NORTH, l);
-
- //
- // Add splash image
- //
- url = cl.getResource(Resources.getString(ICON_BATIK_SPLASH));
- panel.add(BorderLayout.CENTER, new JLabel(new ImageIcon(url)));
-
- //
- // Add exact revision information
- //
- String tagName = Version.getVersion();
-
- panel.add(BorderLayout.SOUTH, new JLabel(tagName, SwingConstants.RIGHT));
-
- setBackground(Color.white);
- getContentPane().setBackground(Color.white);
-
- JPanel p = new JPanel(new BorderLayout());
- p.setBackground(Color.white);
- p.add(panel, BorderLayout.CENTER);
-
- JTextArea contributors
- = new JTextArea(Resources.getString(LABEL_CONTRIBUTORS)){
- {setLineWrap(true); setWrapStyleWord(true); setEnabled(false); setRows(11); }
- };
-
- contributors.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
-
- p.add(contributors,
- BorderLayout.SOUTH);
- ((JComponent)getContentPane()).setBorder
- (BorderFactory.createCompoundBorder
- (BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.gray, Color.black),
- BorderFactory.createCompoundBorder
- (BorderFactory.createCompoundBorder
- (BorderFactory.createEmptyBorder(3, 3, 3, 3),
- BorderFactory.createLineBorder(Color.black)),
- BorderFactory.createEmptyBorder(10, 10, 10, 10))));
-
- getContentPane().add(p);
- pack();
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/Application.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/Application.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/Application.java
deleted file mode 100644
index 75f3c16..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/Application.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.svgbrowser;
-
-import javax.swing.Action;
-
-/**
- * This interface represents a SVG viewer application.
- *
- * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
- * @version $Id: Application.java,v 1.13 2004/08/18 07:12:27 vhardy Exp $
- */
-public interface Application {
-
- /**
- * Creates and shows a new viewer frame.
- */
- JSVGViewerFrame createAndShowJSVGViewerFrame();
-
- /**
- * Closes the given viewer frame.
- */
- void closeJSVGViewerFrame(JSVGViewerFrame f);
-
- /**
- * Creates an action to exit the application.
- */
- Action createExitAction(JSVGViewerFrame vf);
-
- /**
- * Opens the given link in a new window.
- */
- void openLink(String url);
-
- /**
- * Returns the XML parser class name.
- */
- String getXMLParserClassName();
-
- /**
- * Returns true if the XML parser must be in validation mode, false
- * otherwise.
- */
- boolean isXMLParserValidating();
-
- /**
- * Shows the preference dialog.
- */
- void showPreferenceDialog(JSVGViewerFrame f);
-
- /**
- * Returns the user languages.
- */
- String getLanguages();
-
- /**
- * Returns the user stylesheet uri.
- * @return null if no user style sheet was specified.
- */
- String getUserStyleSheetURI();
-
- /**
- * Returns the default value for the CSS
- * "font-family" property
- */
- String getDefaultFontFamily();
-
- /**
- * Returns the CSS media to use.
- * @return empty string if no CSS media was specified.
- */
- String getMedia();
-
- /**
- * Returns true if the selection overlay is painted in XOR mode, false
- * otherwise.
- */
- boolean isSelectionOverlayXORMode();
-
- /**
- * Returns true if the input scriptType can be loaded in
- * this application.
- */
- boolean canLoadScriptType(String scriptType);
-
- /**
- * Returns the allowed origins for scripts.
- * @see ResourceOrigin
- */
- int getAllowedScriptOrigin();
-
- /**
- * Returns the allowed origins for external
- * resources.
- *
- * @see ResourceOrigin
- */
- int getAllowedExternalResourceOrigin();
-
- /**
- * Notifies Application of recently visited URI
- */
- void addVisitedURI(String uri);
-
- /**
- * Asks Application for a list of recently visited URI
- */
- String[] getVisitedURIs();
-
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/FindDialog.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/FindDialog.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/FindDialog.java
deleted file mode 100644
index e17b1cf..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/FindDialog.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
-
- Copyright 2001,2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.svgbrowser;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Frame;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Shape;
-import java.awt.event.ActionEvent;
-import java.awt.geom.AffineTransform;
-import java.awt.geom.Rectangle2D;
-import java.text.AttributedCharacterIterator;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import javax.swing.AbstractAction;
-import javax.swing.Action;
-import javax.swing.BorderFactory;
-import javax.swing.ButtonGroup;
-import javax.swing.JButton;
-import javax.swing.JCheckBox;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JRadioButton;
-import javax.swing.JTextField;
-
-import org.apache.flex.forks.batik.gvt.GVTTreeWalker;
-import org.apache.flex.forks.batik.gvt.GraphicsNode;
-import org.apache.flex.forks.batik.gvt.TextNode;
-import org.apache.flex.forks.batik.gvt.text.Mark;
-import org.apache.flex.forks.batik.swing.JSVGCanvas;
-import org.apache.flex.forks.batik.util.gui.ExtendedGridBagConstraints;
-import org.apache.flex.forks.batik.util.gui.resource.ActionMap;
-import org.apache.flex.forks.batik.util.gui.resource.ButtonFactory;
-import org.apache.flex.forks.batik.util.gui.resource.MissingListenerException;
-import org.apache.flex.forks.batik.util.gui.resource.ResourceManager;
-
-/**
- * This class represents a Dialog that lets the user searching for text inside
- * an SVG document.
- *
- * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: FindDialog.java,v 1.10 2004/08/18 07:12:27 vhardy Exp $
- */
-public class FindDialog extends JDialog implements ActionMap {
-
- /**
- * The resource file name
- */
- protected final static String RESOURCES =
- "org.apache.flex.forks.batik.apps.svgbrowser.resources.FindDialog";
-
- // action names
- public final static String FIND_ACTION = "FindButtonAction";
-
- public final static String CLEAR_ACTION = "ClearButtonAction";
-
- public final static String CLOSE_ACTION = "CloseButtonAction";
-
- /**
- * The resource bundle
- */
- protected static ResourceBundle bundle;
-
- /**
- * The resource manager
- */
- protected static ResourceManager resources;
-
- static {
- bundle = ResourceBundle.getBundle(RESOURCES, Locale.getDefault());
- resources = new ResourceManager(bundle);
- }
-
- /** The button factory */
- protected ButtonFactory buttonFactory;
-
- /** The GVT root into which text is searched. */
- protected GraphicsNode gvtRoot;
-
- /** The GVTTreeWalker used to scan the GVT Tree. */
- protected GVTTreeWalker walker;
-
- /** The current index in the TextNode's string. */
- protected int currentIndex;
-
- /** The TextField that owns the text to search. */
- protected JTextField search;
-
- /** The next button. */
- protected JButton findButton;
-
- /** The next button. */
- protected JButton clearButton;
-
- /** The cancel button. */
- protected JButton closeButton;
-
- /** The case sensitive button. */
- protected JCheckBox caseSensitive;
-
- /** The canvas. */
- protected JSVGCanvas svgCanvas;
-
- /** The highlight button. */
- protected JRadioButton highlightButton;
-
- /** The highlight and center button. */
- protected JRadioButton highlightCenterButton;
-
- /** The highlight center and zoom button. */
- protected JRadioButton highlightCenterZoomButton;
- /**
- * Constructs a new <tt>FindDialog</tt>.
- */
- public FindDialog(JSVGCanvas svgCanvas) {
- this(null, svgCanvas);
- }
-
- /**
- * Constructs a new <tt>FindDialog</tt>.
- */
- public FindDialog(Frame owner, JSVGCanvas svgCanvas) {
- super(owner, resources.getString("Dialog.title"));
- this.svgCanvas = svgCanvas;
-
- buttonFactory = new ButtonFactory(bundle, this);
-
- listeners.put(FIND_ACTION,
- new FindButtonAction());
-
- listeners.put(CLEAR_ACTION,
- new ClearButtonAction());
-
- listeners.put(CLOSE_ACTION,
- new CloseButtonAction());
-
- JPanel p = new JPanel(new BorderLayout());
- p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- p.add(createFindPanel(), BorderLayout.CENTER);
- p.add(createShowResultPanel(), BorderLayout.SOUTH);
-
- getContentPane().add(p, BorderLayout.CENTER);
- getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
- }
-
- /**
- * Creates the Find panel.
- */
- protected JPanel createFindPanel() {
- JPanel panel = new JPanel(new GridBagLayout());
-
- panel.setBorder(BorderFactory.createTitledBorder
- (BorderFactory.createEtchedBorder(),
- resources.getString("Panel.title")));
-
- ExtendedGridBagConstraints gbc = new ExtendedGridBagConstraints();
- gbc.insets = new Insets(2, 2, 2, 2);
-
- gbc.anchor = ExtendedGridBagConstraints.EAST;
- gbc.fill = ExtendedGridBagConstraints.NONE;
- gbc.setWeight(0, 0);
- gbc.setGridBounds(0, 0, 1, 1);
- panel.add(new JLabel(resources.getString("FindLabel.text")), gbc);
-
- gbc.fill = ExtendedGridBagConstraints.HORIZONTAL;
- gbc.setWeight(1.0, 0);
- gbc.setGridBounds(1, 0, 2, 1);
- panel.add(search = new JTextField(20), gbc);
-
- gbc.fill = ExtendedGridBagConstraints.NONE;
- gbc.anchor = ExtendedGridBagConstraints.WEST;
- gbc.setWeight(0, 0);
- gbc.setGridBounds(1, 1, 1, 1);
- caseSensitive = buttonFactory.createJCheckBox("CaseSensitiveCheckBox");
- panel.add(caseSensitive, gbc);
-
- return panel;
- }
-
- protected JPanel createShowResultPanel() {
- JPanel panel = new JPanel(new GridBagLayout());
-
- panel.setBorder(BorderFactory.createTitledBorder
- (BorderFactory.createEtchedBorder(),
- resources.getString("ShowResultPanel.title")));
-
- ExtendedGridBagConstraints gbc = new ExtendedGridBagConstraints();
- gbc.insets = new Insets(2, 2, 2, 2);
-
- gbc.anchor = ExtendedGridBagConstraints.WEST;
- gbc.fill = ExtendedGridBagConstraints.NONE;
- gbc.setWeight(0, 0);
-
- ButtonGroup grp = new ButtonGroup();
-
- highlightButton = buttonFactory.createJRadioButton("Highlight");
- highlightButton.setSelected(true);
- grp.add(highlightButton);
- gbc.setGridBounds(0, 0, 1, 1);
- panel.add(highlightButton, gbc);
-
- highlightCenterButton =
- buttonFactory.createJRadioButton("HighlightAndCenter");
- grp.add(highlightCenterButton);
- gbc.setGridBounds(0, 1, 1, 1);
- panel.add(highlightCenterButton, gbc);
-
- highlightCenterZoomButton =
- buttonFactory.createJRadioButton("HighlightCenterAndZoom");
- grp.add(highlightCenterZoomButton);
- gbc.setGridBounds(0, 2, 1, 1);
- panel.add(highlightCenterZoomButton, gbc);
-
- return panel;
- }
-
- /**
- * Creates the buttons panel
- */
- protected JPanel createButtonsPanel() {
- JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- panel.add(findButton = buttonFactory.createJButton("FindButton"));
- panel.add(clearButton = buttonFactory.createJButton("ClearButton"));
- panel.add(closeButton = buttonFactory.createJButton("CloseButton"));
- return panel;
- }
-
-
- /**
- * Sets the graphics node into which text is searched.
- * @param gvtRoot the GVT root node
- */
- public void setGraphicsNode(GraphicsNode gvtRoot) {
- this.gvtRoot = gvtRoot;
- if (gvtRoot != null) {
- this.walker = new GVTTreeWalker(gvtRoot);
- } else {
- this.walker = null;
- }
- }
-
- /**
- * Returns the next GraphicsNode that matches the specified string or null
- * if any.
- *
- * @param text the text to match
- */
- protected GraphicsNode getNext(String text) {
- if (walker == null && gvtRoot != null) {
- walker = new GVTTreeWalker(gvtRoot);
- }
- GraphicsNode gn = walker.getCurrentGraphicsNode();
- int index = match(gn, text, currentIndex+text.length());
- if (index >= 0) {
- currentIndex = index;
- } else {
- currentIndex = 0;
- gn = walker.nextGraphicsNode();
- while (gn != null &&
- ((currentIndex = match(gn, text, currentIndex)) < 0)) {
- currentIndex = 0;
- gn = walker.nextGraphicsNode();
- }
- }
- return gn;
- }
-
- /**
- * Returns the index inside the specified TextNode of the
- * specified text, or -1 if not found.
- *
- * @param node the graphics node to check
- * @param text the text use to match
- * @param index the index from which to start */
- protected int match(GraphicsNode node, String text, int index) {
- if (!(node instanceof TextNode)
- || !node.isVisible()
- || text == null || text.length() == 0) {
- return -1;
- }
- String s = ((TextNode)node).getText();
- if (!caseSensitive.isSelected()) {
- s = s.toLowerCase();
- text = text.toLowerCase();
- }
- return s.indexOf(text, index);
- }
-
- /**
- * Shows the current selected <tt>TextNode</tt>.
- */
- protected void showSelectedGraphicsNode() {
- GraphicsNode gn = walker.getCurrentGraphicsNode();
- if (!(gn instanceof TextNode)) {
- return;
- }
- TextNode textNode = (TextNode)gn;
- // mark the selection of the substring found
- String text = textNode.getText();
- String pattern = search.getText();
- if (!caseSensitive.isSelected()) {
- text = text.toLowerCase();
- pattern = pattern.toLowerCase();
- }
- int end = text.indexOf(pattern, currentIndex);
-
- AttributedCharacterIterator aci =
- textNode.getAttributedCharacterIterator();
- aci.first();
- for (int i=0; i < end; ++i) {
- aci.next();
- }
- Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true);
-
- for (int i = 0; i < pattern.length()-1; ++i) {
- aci.next();
- }
- Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false);
- svgCanvas.select(startMark, endMark);
-
- // zoom on the TextNode if needed
- if (highlightButton.isSelected()) {
- return;
- }
-
- // get the highlight shape in GVT root (global) coordinate sytem
- Shape s = textNode.getHighlightShape();
- AffineTransform at;
- if (highlightCenterZoomButton.isSelected()) {
- at = svgCanvas.getInitialTransform();
- } else {
- at = svgCanvas.getRenderingTransform();
- }
- // get the bounds of the highlight shape in the canvas coordinate system
- Rectangle2D gnb = at.createTransformedShape(s).getBounds();
-
- Dimension canvasSize = svgCanvas.getSize();
- // translate the highlight region to (0, 0) in the canvas coordinate
- // system
- AffineTransform Tx = AffineTransform.getTranslateInstance
- (-gnb.getX()-gnb.getWidth()/2,
- -gnb.getY()-gnb.getHeight()/2);
-
- if (highlightCenterZoomButton.isSelected()) {
- // zoom on the highlight shape such as the shape takes x% of the
- // canvas size
- double sx = canvasSize.width/gnb.getWidth();
- double sy = canvasSize.height/gnb.getHeight();
- double scale = Math.min(sx, sy) / 8;
- if (scale > 1) {
- Tx.preConcatenate
- (AffineTransform.getScaleInstance(scale, scale));
- }
- }
- Tx.preConcatenate(AffineTransform.getTranslateInstance
- (canvasSize.width/2, canvasSize.height/2));
- // take into account the initial transform
- AffineTransform newRT = new AffineTransform(at);
- newRT.preConcatenate(Tx);
- // change the rendering transform
- svgCanvas.setRenderingTransform(newRT);
- }
-
- // ActionMap implementation
-
- /**
- * The map that contains the listeners
- */
- protected Map listeners = new HashMap(10);
-
- /**
- * Returns the action associated with the given string
- * or null on error
- * @param key the key mapped with the action to get
- * @throws MissingListenerException if the action is not found
- */
- public Action getAction(String key) throws MissingListenerException {
- return (Action)listeners.get(key);
- }
-
- //////////////////////////////////////////////////////////////////////////
- // Action implementation
- //////////////////////////////////////////////////////////////////////////
-
- /**
- * The action associated to the 'find' button.
- */
- protected class FindButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- String text = search.getText();
- if (text == null || text.length() == 0) {
- return;
- }
- GraphicsNode gn = getNext(text);
- if (gn != null) {
- showSelectedGraphicsNode();
- } else {
- // end of document reached
- walker = null;
- JOptionPane.showMessageDialog(FindDialog.this,
- resources.getString("End.text"),
- resources.getString("End.title"),
- JOptionPane.INFORMATION_MESSAGE);
- }
- }
- }
-
- /**
- * The action associated to the 'clear' button.
- */
- protected class ClearButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- search.setText(null);
- walker = null;
- }
- }
-
- /**
- * The action associated to the 'close' button.
- */
- protected class CloseButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- dispose();
- }
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JAuthenticator.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JAuthenticator.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JAuthenticator.java
deleted file mode 100644
index b6390604..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JAuthenticator.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
-
- Copyright 2002-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.svgbrowser;
-
-import java.awt.BorderLayout;
-import java.awt.Container;
-import java.awt.EventQueue;
-import java.awt.Frame;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JPasswordField;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-
-/**
- * This class is resposible for providing authentication information
- * when needed by network protocols. It does this by poping up a small
- * window that asks for User ID and password for the system.
- */
-public class JAuthenticator extends Authenticator {
-
- /**
- * Internationalization message string
- */
- public static final String TITLE
- = "JAuthenticator.title";
- public static final String LABEL_SITE
- = "JAuthenticator.label.site";
- public static final String LABEL_REQ
- = "JAuthenticator.label.req";
- public static final String LABEL_USERID
- = "JAuthenticator.label.userID";
- public static final String LABEL_PASSWORD
- = "JAuthenticator.label.password";
-
- public static final String LABEL_CANCEL
- = "JAuthenticator.label.cancel";
- public static final String LABEL_OK
- = "JAuthenticator.label.ok";
-
- protected JDialog window;
- protected JButton cancelButton;
- protected JButton okButton;
-
- protected JLabel label1;
- protected JLabel label2;
- protected JTextField JUserID;
- protected JPasswordField JPassword;
-
- Object lock = new Object();
-
- private boolean result;
- private boolean wasNotified;
- private String userID;
- private char [] password;
-
- public JAuthenticator() {
- initWindow();
- }
-
- protected void initWindow() {
- String title = Resources.getString(TITLE);
- window = new JDialog((Frame)null, title, true);
-
- Container mainPanel = window.getContentPane();
- mainPanel.setLayout(new BorderLayout());
- mainPanel.add(buildAuthPanel(), BorderLayout.CENTER);
- mainPanel.add(buildButtonPanel(), BorderLayout.SOUTH);
- window.pack();
-
- window.addWindowListener( new WindowAdapter() {
- public void windowClosing(WindowEvent e) {
- cancelListener.actionPerformed
- (new ActionEvent(e.getWindow(),
- ActionEvent.ACTION_PERFORMED,
- "Close"));
- }
- });
- }
-
- protected JComponent buildAuthPanel() {
- GridBagLayout gridBag = new GridBagLayout();
- GridBagConstraints c = new GridBagConstraints();
- JPanel proxyPanel = new JPanel(gridBag);
- c.fill = GridBagConstraints.BOTH;
- c.weightx = 1.0;
-
- c.gridwidth = 1;
- JLabel labelS = new JLabel(Resources.getString(LABEL_SITE));
- labelS.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(labelS, c);
- proxyPanel.add(labelS);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- label1 = new JLabel("");
- label1.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(label1, c);
- proxyPanel.add(label1);
-
- c.gridwidth = 1;
- JLabel labelR = new JLabel(Resources.getString(LABEL_REQ));
- labelR.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(labelR, c);
- proxyPanel.add(labelR);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- label2 = new JLabel("");
- label2.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(label2, c);
- proxyPanel.add(label2);
-
- c.gridwidth = 1;
- JLabel labelUserID = new JLabel(Resources.getString(LABEL_USERID));
- labelUserID.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(labelUserID, c);
- proxyPanel.add(labelUserID);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- JUserID = new JTextField(20);
- gridBag.setConstraints(JUserID, c);
- proxyPanel.add(JUserID);
-
- c.gridwidth = 1;
- JLabel labelPassword = new JLabel(Resources.getString(LABEL_PASSWORD));
- labelPassword.setHorizontalAlignment(SwingConstants.LEFT);
- gridBag.setConstraints(labelPassword, c);
- proxyPanel.add(labelPassword);
-
- c.gridwidth = GridBagConstraints.REMAINDER;
- JPassword = new JPasswordField(20);
- JPassword.setEchoChar('*');
- JPassword.addActionListener(okListener);
- gridBag.setConstraints(JPassword, c);
- proxyPanel.add(JPassword);
-
- return proxyPanel;
- }
-
-
-
- protected JComponent buildButtonPanel() {
- JPanel buttonPanel = new JPanel();
- cancelButton = new JButton(Resources.getString(LABEL_CANCEL));
- cancelButton.addActionListener(cancelListener);
- buttonPanel.add(cancelButton);
-
- okButton = new JButton(Resources.getString(LABEL_OK));
- okButton.addActionListener( okListener);
- buttonPanel.add(okButton);
-
- return buttonPanel;
- }
-
- /**
- * This is called by the protocol stack when authentication is
- * required. We then show the dialog in the Swing event thread,
- * and block waiting for the user to select either cancel or ok,
- * at which point we get notified.
- */
- public PasswordAuthentication getPasswordAuthentication() {
- synchronized (lock) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- label1.setText(getRequestingSite().getHostName());
- label2.setText(getRequestingPrompt());
- window.setVisible(true);
- }
- });
- wasNotified = false;
- while (!wasNotified) {
- try {
- lock.wait();
- } catch(InterruptedException ie) { }
- }
- if (!result)
- return null;
-
- return new PasswordAuthentication(userID, password);
- }
- }
-
- ActionListener okListener = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- synchronized (lock) {
- window.setVisible(false);
-
- userID = JUserID.getText();
- password = JPassword.getPassword();
- JPassword.setText("");
- result = true;
- wasNotified = true;
- lock.notifyAll();
- }
- }
- };
-
- ActionListener cancelListener = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- synchronized (lock) {
- window.setVisible(false);
-
- userID = null;
- JUserID.setText("");
- password = null;
- JPassword.setText("");
- result = false;
- wasNotified = true;
- lock.notifyAll();
- }
- }
- };
-}
http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/f690ea2f/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JPEGOptionPanel.java
----------------------------------------------------------------------
diff --git a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JPEGOptionPanel.java b/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JPEGOptionPanel.java
deleted file mode 100644
index dfc2f3b..0000000
--- a/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/apps/svgbrowser/JPEGOptionPanel.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-
- Copyright 2001-2003 The Apache Software Foundation
-
- Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
- */
-package org.apache.flex.forks.batik.apps.svgbrowser;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.util.Hashtable;
-
-import javax.swing.BorderFactory;
-import javax.swing.JLabel;
-import javax.swing.JSlider;
-
-import org.apache.flex.forks.batik.util.gui.ExtendedGridBagConstraints;
-
-/**
- * This class represents a panel to control jpeg encoding quality.
- *
- * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
- * @version $Id: JPEGOptionPanel.java,v 1.5 2004/08/18 07:12:27 vhardy Exp $
- */
-public class JPEGOptionPanel extends OptionPanel {
- /**
- * The jpeg encoding quality.
- */
- protected JSlider quality;
-
- /**
- * Creates a new panel.
- */
- public JPEGOptionPanel() {
- super(new GridBagLayout());
-
- ExtendedGridBagConstraints constraints =
- new ExtendedGridBagConstraints();
-
-
- constraints.insets = new Insets(5, 5, 5, 5);
-
- constraints.weightx = 0;
- constraints.weighty = 0;
- constraints.fill = GridBagConstraints.NONE;
- constraints.setGridBounds(0, 0, 1, 1);
- add(new JLabel(resources.getString("JPEGOptionPanel.label")),
- constraints);
-
- quality = new JSlider();
- quality.setMinimum(0);
- quality.setMaximum(100);
- quality.setMajorTickSpacing(10);
- quality.setMinorTickSpacing(5);
- quality.setPaintTicks(true);
- quality.setPaintLabels(true);
- quality.setBorder(BorderFactory.createEmptyBorder(0,0,10,0));
- Hashtable labels = new Hashtable();
- for (int i=0; i < 100; i+=10) {
- labels.put(new Integer(i), new JLabel("0."+i/10));
- }
- labels.put(new Integer(100), new JLabel("1"));
- quality.setLabelTable(labels);
-
- Dimension dim = quality.getPreferredSize();
- quality.setPreferredSize(new Dimension(350, dim.height));
-
- constraints.weightx = 1.0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.setGridBounds(1, 0, 1, 1);
- add(quality, constraints);
- }
-
- /**
- * Returns the jpeg quality.
- */
- public float getQuality() {
- return quality.getValue()/100f;
- }
-
- /**
- * Shows a dialog to choose the jpeg encoding quality and return
- * the quality as a float.
- */
- public static float showDialog(Component parent) {
- String title = resources.getString("JPEGOptionPanel.dialog.title");
- JPEGOptionPanel panel = new JPEGOptionPanel();
- Dialog dialog = new Dialog(parent, title, panel);
- dialog.pack();
- dialog.show();
- return panel.getQuality();
- }
-}