You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-commits@xmlgraphics.apache.org by ca...@apache.org on 2006/11/16 12:16:21 UTC
svn commit: r475685 [31/35] - in /xmlgraphics/batik/trunk: ./
contrib/charts/xsl/ contrib/rasterizertask/
contrib/rasterizertask/sources/org/apache/tools/ant/taskdefs/optional/
contrib/scroll/ resources/org/apache/batik/apps/svgbrowser/resources/
resou...
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGScrollPane.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGScrollPane.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGScrollPane.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/JSVGScrollPane.java Thu Nov 16 03:16:05 2006
@@ -32,7 +32,7 @@
import java.awt.geom.Rectangle2D;
import java.awt.geom.AffineTransform;
-import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentEvent;
import javax.swing.BoundedRangeModel;
import javax.swing.JScrollBar;
@@ -69,21 +69,22 @@
/**
-* This is implements a 2D scroller that will scroll an JSVGCanvas.
-* <p>
-* Reimplimentation, rather than imlementing the Scrollable interface,
-* provides several advantages. The main advantage is the ability to
-* more precisely control ScrollBar events; fewer JSVGCanvas updates
-* are required when scrolling. This creates a significant performance
-* (reflected by an increase in scroll speed) advantage compared to
-* implementating the Scrollable interface.
-* <p>
-* @author Zach DelProposto
-*/
+ * A Swing component that consists of a JSVGCanvas with optional scroll
+ * bars.
+ * <p>
+ * Reimplementation, rather than imlementing the Scrollable interface,
+ * provides several advantages. The main advantage is the ability to
+ * control more precisely ScrollBar events; fewer JSVGCanvas updates
+ * are required when scrolling. This creates a significant performance
+ * (reflected by an increase in scroll speed) advantage compared to
+ * implementing the Scrollable interface.
+ * </p>
+ * @author Zach DelProposto
+ */
public class JSVGScrollPane extends JPanel
{
protected JSVGCanvas canvas;
-
+
protected JPanel horizontalPanel;
protected JScrollBar vertical;
protected JScrollBar horizontal;
@@ -92,13 +93,12 @@
protected SBListener hsbListener;
protected SBListener vsbListener;
-
- protected Rectangle2D viewBox = null; // SVG Root element viewbox
+
+ protected Rectangle2D viewBox = null; // SVG Root element viewbox
protected boolean ignoreScrollChange = false;
-
+
/**
- * Creates a JSVGScrollPane, which will scroll an JSVGCanvas.
- *
+ * Creates a JSVGScrollPane, which will scroll an JSVGCanvas.
*/
public JSVGScrollPane(JSVGCanvas canvas)
{
@@ -109,36 +109,36 @@
// create components
vertical = new JScrollBar(JScrollBar.VERTICAL, 0, 0, 0, 0);
horizontal = new JScrollBar(JScrollBar.HORIZONTAL, 0, 0, 0, 0);
-
+
// create a spacer next to the horizontal bar
horizontalPanel = new JPanel(new BorderLayout());
horizontalPanel.add(horizontal, BorderLayout.CENTER);
cornerBox = Box.createRigidArea
- (new Dimension(vertical.getPreferredSize().width,
+ (new Dimension(vertical.getPreferredSize().width,
horizontal.getPreferredSize().height));
horizontalPanel.add(cornerBox, BorderLayout.EAST);
-
+
// listeners
hsbListener = createScrollBarListener(false);
horizontal.getModel().addChangeListener(hsbListener);
-
+
vsbListener = createScrollBarListener(true);
vertical.getModel().addChangeListener(vsbListener);
-
+
// by default, scrollbars are not needed
updateScrollbarState(false, false);
-
+
// addMouseWheelListener(new WheelListener());
-
+
// layout
setLayout(new BorderLayout());
add(canvas, BorderLayout.CENTER);
add(vertical, BorderLayout.EAST);
add(horizontalPanel, BorderLayout.SOUTH);
-
+
// inform of ZOOM events (to print sizes, such as in a status bar)
canvas.addSVGDocumentLoaderListener(createLoadListener());
-
+
// canvas listeners
ScrollListener xlistener = createScrollListener();
this.addComponentListener(xlistener);
@@ -171,7 +171,7 @@
protected ScrollListener createScrollListener() {
return new ScrollListener();
}
-
+
/**
* Factory method so subclasses can override the default load listener.
@@ -179,7 +179,7 @@
protected SVGDocumentLoaderListener createLoadListener() {
return new SVGScrollDocumentLoaderListener();
}
-
+
public JSVGCanvas getCanvas() {
return canvas;
}
@@ -191,25 +191,25 @@
= (NodeEventTarget) e.getSVGDocument().getRootElement();
root.addEventListenerNS
(XMLConstants.XML_EVENTS_NAMESPACE_URI,
- SVGConstants.SVG_SVGZOOM_EVENT_TYPE,
+ SVGConstants.SVG_SVGZOOM_EVENT_TYPE,
new EventListener() {
public void handleEvent(Event evt) {
if (!(evt.getTarget() instanceof SVGSVGElement))
return;
- // assert(evt.getType() ==
+ // assert(evt.getType() ==
// SVGConstants.SVG_SVGZOOM_EVENT_TYPE);
SVGSVGElement svg = (SVGSVGElement) evt.getTarget();
scaleChange(svg.getCurrentScale());
} // handleEvent()
}, false, null);
- }// documentLoadingCompleted()
+ }// documentLoadingCompleted()
};
-
-
+
+
/**
- * Resets this object (for reloads),
- * releasing any cached data and recomputing
- * scroll extents.
+ * Resets this object (for reloads),
+ * releasing any cached data and recomputing
+ * scroll extents.
*/
public void reset()
{
@@ -217,11 +217,11 @@
updateScrollbarState(false, false);
revalidate();
}// reset()
-
-
+
+
/**
- * Sets the translation portion of the transform based upon the
- * current scroll bar position
+ * Sets the translation portion of the transform based upon the
+ * current scroll bar position
*/
protected void setScrollPosition() {
checkAndSetViewBoxRect();
@@ -249,29 +249,29 @@
(AffineTransform.getTranslateInstance(-deltaX, -deltaY));
canvas.setRenderingTransform(crt);
}// setScrollPosition()
-
-
-
- /**
- * MouseWheel Listener
- * <p>
- * Provides mouse wheel support. The mouse wheel will scroll the currently
- * displayed scroll bar, if only one is displayed. If two scrollbars are
- * displayed, the mouse wheel will only scroll the vertical scrollbar.
+
+
+
+ /**
+ * MouseWheel listener.
+ * <p>
+ * Provides mouse wheel support. The mouse wheel will scroll the currently
+ * displayed scroll bar, if only one is displayed. If two scrollbars are
+ * displayed, the mouse wheel will only scroll the vertical scrollbar.
+ *
+ * This is commented out because it requires JDK 1.4 and currently
+ * Batik targets JDK 1.3.
*
- * This is commented out because it requires JDK 1.4 and currently
- * Batik targets JDK 1.3.
- *
- * TODO Move this to a JDK 1.4 specific class in sources-1.4.
+ * TODO Move this to a JDK 1.4 specific class in sources-1.4.
*/
/*
protected class WheelListener implements MouseWheelListener
{
public void mouseWheelMoved(MouseWheelEvent e)
{
- final JScrollBar sb = (vertical.isVisible()) ?
- vertical : horizontal; // vertical is preferred
-
+ final JScrollBar sb = (vertical.isVisible()) ?
+ vertical : horizontal; // vertical is preferred
+
if(e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
final int amt = e.getUnitsToScroll() * sb.getUnitIncrement();
sb.setValue(sb.getValue() + amt);
@@ -279,27 +279,29 @@
final int amt = e.getWheelRotation() * sb.getBlockIncrement();
sb.setValue(sb.getValue() + amt);
}
-
+
}// mouseWheelMoved()
}// inner class WheelListener
*/
-
-
+
+
/**
- * Advanced JScrollBar listener.
- * <p>
- * <b>A separate listener must be attached to each scrollbar,
- * since we keep track of mouse state for each scrollbar
- * separately!</b>
- * <p>
- * This coalesces drag events so we don't track them, and
- * 'passes through' click events. It doesn't coalesce as many
- * events as it should, but it helps * considerably.
+ * Advanced JScrollBar listener.
+ * <p>
+ * <b>A separate listener must be attached to each scrollbar,
+ * since we keep track of mouse state for each scrollbar
+ * separately!</b>
+ * </p>
+ * <p>
+ * This coalesces drag events so we don't track them, and
+ * 'passes through' click events. It doesn't coalesce as many
+ * events as it should, but it helps considerably.
+ * </p>
*/
protected class SBListener implements ChangeListener
{
// 'true' if we are in a drag (versus a click)
- protected boolean inDrag = false;
+ protected boolean inDrag = false;
protected int startValue;
protected boolean isVertical;
@@ -308,7 +310,7 @@
{
isVertical = vertical;
}// SBListener()
-
+
public synchronized void stateChanged(ChangeEvent e)
{
// only respond to changes if we are NOT being dragged
@@ -316,7 +318,7 @@
if(ignoreScrollChange) return;
Object src = e.getSource();
- if (!(src instanceof BoundedRangeModel))
+ if (!(src instanceof BoundedRangeModel))
return;
int val = ((isVertical)?vertical.getValue():
@@ -350,30 +352,30 @@
}
}// stateChanged()
}// inner class SBListener
-
+
/** Handle scroll, zoom, and resize events */
- protected class ScrollListener extends ComponentAdapter
- implements JGVTComponentListener, GVTTreeBuilderListener,
+ protected class ScrollListener extends ComponentAdapter
+ implements JGVTComponentListener, GVTTreeBuilderListener,
GVTTreeRendererListener, UpdateManagerListener
{
protected boolean isReady = false;
-
+
public void componentTransformChanged(ComponentEvent evt)
{
if(isReady)
resizeScrollBars();
}// componentTransformChanged()
-
-
+
+
public void componentResized(ComponentEvent evt)
{
if(isReady)
resizeScrollBars();
}// componentResized()
-
-
- public void gvtBuildStarted (GVTTreeBuilderEvent e) {
+
+
+ public void gvtBuildStarted (GVTTreeBuilderEvent e) {
isReady = false;
// Start by assuming we won't need them.
updateScrollbarState(false, false);
@@ -383,7 +385,7 @@
isReady = true;
viewBox = null; // new document forget old viewBox if any.
}// gvtRenderingCompleted()
-
+
public void gvtRenderingCompleted(GVTTreeRendererEvent e) {
if (viewBox == null) {
resizeScrollBars();
@@ -400,7 +402,7 @@
}
}
- public void updateCompleted(UpdateManagerEvent e) {
+ public void updateCompleted(UpdateManagerEvent e) {
if (viewBox == null) {
resizeScrollBars();
return;
@@ -415,7 +417,7 @@
resizeScrollBars();
}
}
-
+
public void gvtBuildCancelled(GVTTreeBuilderEvent e) { }
public void gvtBuildFailed (GVTTreeBuilderEvent e) { }
@@ -433,11 +435,11 @@
public void updateFailed (UpdateManagerEvent e) { }
}// inner class ScrollListener
-
-
+
+
/**
- * Compute the scrollbar extents, and determine if
- * scrollbars should be visible.
+ * Compute the scrollbar extents, and determine if
+ * scrollbars should be visible.
*
*/
protected void resizeScrollBars()
@@ -464,7 +466,7 @@
if (r2d.y > 0) maxH += r2d.y;
else ty -= r2d.y;
- // System.err.println(" maxW = "+maxW+"; maxH = "+maxH +
+ // System.err.println(" maxW = "+maxW+"; maxH = "+maxH +
// " tx = "+tx+"; ty = "+ty);
// Changing scrollbar visibility may change the
@@ -474,18 +476,18 @@
// set scroll params
vertical. setValues(ty, vpSize.height, 0, maxH);
horizontal.setValues(tx, vpSize.width, 0, maxW);
-
- // set block scroll; this should be equal to a full 'page',
+
+ // set block scroll; this should be equal to a full 'page',
// minus a small amount to keep a portion in view
// that small amount is 10%.
vertical. setBlockIncrement( (int) (0.9f * vpSize.height) );
horizontal.setBlockIncrement( (int) (0.9f * vpSize.width) );
-
+
// set unit scroll. This is arbitrary, but we define
- // it to be 20% of the current viewport.
+ // it to be 20% of the current viewport.
vertical. setUnitIncrement( (int) (0.2f * vpSize.height) );
horizontal.setUnitIncrement( (int) (0.2f * vpSize.width) );
-
+
doLayout();
horizontalPanel.doLayout();
horizontal.doLayout();
@@ -537,7 +539,7 @@
hNeeded = (maxW > maxVPW) || (tx != 0);
vNeeded = (maxH > maxVPH) || (ty != 0);
// System.err.println("Vis flags: " + hNeeded +", " + vNeeded);
-
+
// This makes sure that if one scrollbar is visible
// we 'recheck' the other scroll bar with the minVPW/H
// since making one visible makes the room for displaying content
@@ -555,7 +557,7 @@
// Return the new size of the canvas.
return ret;
}
-
+
protected void updateScrollbarState(boolean hNeeded, boolean vNeeded) {
horizontal.setEnabled(hNeeded);
vertical .setEnabled(vNeeded);
@@ -571,9 +573,9 @@
}
}
- /**
- * Derives the SVG Viewbox from the SVG root element.
- * Caches it. Assumes that it will not change.
+ /**
+ * Derives the SVG Viewbox from the SVG root element.
+ * Caches it. Assumes that it will not change.
*
*/
protected void checkAndSetViewBoxRect() {
@@ -596,7 +598,7 @@
(null, SVGConstants.SVG_VIEW_BOX_ATTRIBUTE);
if (viewBoxStr.length() != 0) {
float[] rect = ViewBox.parseViewBoxAttribute(el, viewBoxStr, null);
- return new Rectangle2D.Float(rect[0], rect[1],
+ return new Rectangle2D.Float(rect[0], rect[1],
rect[2], rect[3]);
}
GraphicsNode gn = canvas.getGraphicsNode();
@@ -605,11 +607,11 @@
return (Rectangle2D)gn.getBounds().clone();
}
- /**
- * Called when the scale size changes. The scale factor
- * (1.0 == original size). By default, this method does
- * nothing, but may be overidden to display a scale
- * (zoom) factor in a status bar, for example.
+ /**
+ * Called when the scale size changes. The scale factor
+ * (1.0 == original size). By default, this method does
+ * nothing, but may be overidden to display a scale
+ * (zoom) factor in a status bar, for example.
*/
public void scaleChange(float scale) {
// do nothing
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/gvt/AbstractJGVTComponent.java Thu Nov 16 03:16:05 2006
@@ -1068,7 +1068,7 @@
(e.getComponent(),
MouseEvent.MOUSE_CLICKED,
e.getWhen(),
- e.getModifiers(), // modifiers
+ e.getModifiers(),
e.getX(),
e.getY(),
e.getClickCount(),
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/swing/svg/AbstractJSVGComponent.java Thu Nov 16 03:16:05 2006
@@ -3311,17 +3311,17 @@
return XMLResourceDescriptor.getXMLParserClassName();
}
- /**
- * Returns true if the XML parser must be in validation mode, false
- * otherwise depending on the SVGUserAgent.
- */
- public boolean isXMLParserValidating() {
+ /**
+ * Returns true if the XML parser must be in validation mode, false
+ * otherwise depending on the SVGUserAgent.
+ */
+ public boolean isXMLParserValidating() {
if (svgUserAgent != null) {
return svgUserAgent.isXMLParserValidating();
}
return false;
- }
-
+ }
+
/**
* Returns the <code>AffineTransform</code> currently
* applied to the drawing by the UserAgent.
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/XMLAbstractTranscoder.java Thu Nov 16 03:16:05 2006
@@ -56,7 +56,7 @@
* Constructs a new <tt>XMLAbstractTranscoder</tt>.
*/
protected XMLAbstractTranscoder() {
- hints.put(KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
+ hints.put(KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
}
/**
@@ -85,7 +85,7 @@
(String)hints.get(KEY_DOCUMENT_ELEMENT);
DOMImplementation domImpl =
(DOMImplementation)hints.get(KEY_DOM_IMPLEMENTATION);
-
+
if (parserClassname == null) {
parserClassname = XMLResourceDescriptor.getXMLParserClassName();
}
@@ -106,9 +106,9 @@
}
// parse the XML document
DocumentFactory f = createDocumentFactory(domImpl, parserClassname);
- boolean b =
- ((Boolean)hints.get(KEY_XML_PARSER_VALIDATING)).booleanValue();
- f.setValidating(b);
+ boolean b =
+ ((Boolean)hints.get(KEY_XML_PARSER_VALIDATING)).booleanValue();
+ f.setValidating(b);
try {
if (input.getInputStream() != null) {
document = f.createDocument(namespaceURI,
@@ -159,7 +159,7 @@
*/
protected DocumentFactory createDocumentFactory(DOMImplementation domImpl,
String parserClassname) {
- return new SAXDocumentFactory(domImpl, parserClassname);
+ return new SAXDocumentFactory(domImpl, parserClassname);
}
/**
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/AbstractWMFReader.java Thu Nov 16 03:16:05 2006
@@ -31,8 +31,8 @@
/** This class provides a general framework to read WMF Metafiles.
*/
public abstract class AbstractWMFReader {
- public static final float PIXEL_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
- public static final float MM_PER_PIXEL = 25.4f / Toolkit.getDefaultToolkit().getScreenResolution();
+ public static final float PIXEL_PER_INCH = Toolkit.getDefaultToolkit().getScreenResolution();
+ public static final float MM_PER_PIXEL = 25.4f / Toolkit.getDefaultToolkit().getScreenResolution();
protected int left, right, top, bottom, width, height, inch;
protected float scaleX, scaleY;
protected int vpW, vpH, vpX, vpY;
@@ -41,9 +41,9 @@
protected int mtMaxRecord, mtNoParameters;
protected int windowWidth, windowHeight;
transient protected int numObjects;
- transient protected Vector objectVector;
- transient public int lastObjectIdx;
-
+ transient protected Vector objectVector;
+ transient public int lastObjectIdx;
+
public AbstractWMFReader() {
scaleX = 1;
scaleY = 1;
@@ -54,15 +54,15 @@
right = left + width;
bottom = top + height;
numObjects = 0;
- objectVector = new Vector();
+ objectVector = new Vector();
}
-
+
public AbstractWMFReader(int width, int height) {
this();
this.width = width;
this.height = height;
}
-
+
/** read the next short ( 2 bytes) value in the DataInputStream.
*/
protected short readShort(DataInputStream is ) throws IOException {
@@ -75,7 +75,7 @@
}
/** read the next int ( 4 bytes) value in the DataInputStream.
- */
+ */
protected int readInt( DataInputStream is ) throws IOException {
byte js[] = new byte[ 4 ];
is.read( js );
@@ -85,7 +85,7 @@
i |= ((0xff) & js[ 0 ] );
return i;
}
-
+
/**
* Returns the viewport width, in Metafile Units
*/
@@ -98,7 +98,7 @@
*/
public float getViewportHeightUnits() {
return vpH;
- }
+ }
/**
* Returns the viewport width, in inches.
@@ -112,8 +112,8 @@
*/
public float getViewportHeightInch() {
return PIXEL_PER_INCH * (float)vpH / (float)inch;
- }
-
+ }
+
/** Return the number of pixels per unit.
*/
public float getPixelsPerUnit() {
@@ -132,59 +132,59 @@
*/
public int getVpH() {
return (int)(PIXEL_PER_INCH * (float)vpH / (float)inch);
- }
-
+ }
+
/** get the left units in the WMF Metafile. This value is given
* in the Aldus Placable Metafile.
- */
+ */
public int getLeftUnits() {
return left;
}
/** get the right units in the WMF Metafile. This value is given
* in the Aldus Placable Header.
- */
+ */
public int getRightUnits() {
return right;
}
/** get the top units in the WMF Metafile. This value is given
* in the Aldus Placable Header.
- */
+ */
public int getTopUnits() {
return top;
}
/** get the width units in the WMF Metafile. This value is given
* in the Aldus Placable Header.
- */
+ */
public int getWidthUnits() {
return width;
}
/** get the height units in the WMF Metafile. This value is given
* in the Aldus Placable Header.
- */
+ */
public int getHeightUnits() {
return height;
}
/** get the bottom units in the WMF Metafile. This value is given
* in the Aldus Placable Header.
- */
+ */
public int getBottomUnits() {
return bottom;
}
-
- /** get the number of Metafile units per inch in the WMF Metafile.
+
+ /** get the number of Metafile units per inch in the WMF Metafile.
* This value is given in the Aldus Placable Header.
*/
public int getMetaFileUnitsPerInch() {
return inch;
}
-
- /** get the Rectangle defining the viewport of the WMF Metafile, in Metafile units.
- * This viewport is defined in the Aldus Placable Header, by its left, top, bottom, right
+
+ /** get the Rectangle defining the viewport of the WMF Metafile, in Metafile units.
+ * This viewport is defined in the Aldus Placable Header, by its left, top, bottom, right
* components.
* @see #getRightUnits()
* @see #getLeftUnits()
@@ -195,7 +195,7 @@
Rectangle rec = new Rectangle(left, top, width, height);
return rec;
}
-
+
/** get the Rectangle defining the viewport of the WMF Metafile, in pixels.
*/
public Rectangle2D getRectanglePixel() {
@@ -203,9 +203,9 @@
float _right = PIXEL_PER_INCH * (float)right / (float)inch;
float _top = PIXEL_PER_INCH * (float)top / (float)inch;
float _bottom = PIXEL_PER_INCH * (float)bottom / (float)inch;
-
+
Rectangle2D.Float rec = new Rectangle2D.Float(_left, _top, _right - _left, _bottom - _top);
-
+
return rec;
}
@@ -216,42 +216,42 @@
float _right = (float)right / (float)inch;
float _top = (float)top / (float)inch;
float _bottom = (float)bottom / (float)inch;
-
+
Rectangle2D.Float rec = new Rectangle2D.Float(_left, _top, _right - _left, _bottom - _top);
-
+
return rec;
- }
-
+ }
+
/** get the width of the WMF Metafile, in pixels.
- */
+ */
public int getWidthPixels() {
return (int)(PIXEL_PER_INCH * (float)width / (float)inch);
}
-
+
/** get the factor to transform Metafile dimensions in pixels
- */
+ */
public float getUnitsToPixels() {
return (PIXEL_PER_INCH / (float)inch);
- }
+ }
/** get the factor to transform logical units width in pixels
- */
+ */
public float getVpWFactor() {
return (PIXEL_PER_INCH * (float)width / (float)inch) / (float)vpW;
- }
+ }
/** get the factor to transform logical units height in pixels
- */
+ */
public float getVpHFactor() {
return (PIXEL_PER_INCH * (float)height / (float)inch) / (float)vpH;
- }
-
+ }
+
/** get the height of the WMF Metafile, in pixels.
- */
+ */
public int getHeightPixels() {
return (int)(PIXEL_PER_INCH * (float)height / (float)inch);
}
-
+
synchronized protected void setReading( boolean state ){
bReading = state;
}
@@ -260,12 +260,12 @@
*/
synchronized public boolean isReading(){
return bReading;
- }
-
+ }
+
/** resets this WMFReader.
*/
public abstract void reset();
-
+
/** Read this InputStream records. The aldus placeable header have already been
* read (see {@link #read(DataInputStream)}). The behavior of this method is left
* to the subclass.
@@ -276,7 +276,7 @@
* <li>the function parameters, according to the WMF Metafile specification.
* the remaining size in short words (16 bits) for the parameters is equal to
* the total size for the record minus 3 short words (= 16 + 32 bits)</li>
- * </ul>
+ * </ul>
* </p>
* <p>Example :</p>
* <pre>while (functionId > 0) {
@@ -286,7 +286,7 @@
* functionId = readShort( is );
* if ( functionId <= 0 )
* break;
- * switch ( functionId ) {
+ * switch ( functionId ) {
* case WMFConstants.<a WMF function ID> {
* do something when this function is encountered
* }
@@ -300,22 +300,22 @@
* @see WMFConstants
*/
protected abstract boolean readRecords(DataInputStream is) throws IOException;
-
- /** Reads the WMF file from the specified Stream. This method read the
+
+ /** Reads the WMF file from the specified Stream. This method read the
* aldus placeable header and set the corresponding properties :
* <ul>
- * <li>{@link #mtType} : File type (0 : memory, 1 : disk)</li>
- * <li>{@link #mtHeaderSize} : Size of header in WORDS (always 9)</li>
- * <li>{@link #mtVersion} : Version of Microsoft Windows used</li>
- * <li>{@link #mtSize} : Total size of the metafile in WORDs</li>
- * <li>{@link #mtNoObjects} : Number of objects in the file</li>
- * <li>{@link #mtMaxRecord} : The size of largest record in WORDs</li>
- * <li>{@link #mtNoParameters} : Not Used (always 0)</li>
- * <li>{@link #left} : Left coordinate in metafile units</li>
- * <li>{@link #right} : Right coordinate in metafile units</li>
- * <li>{@link #top} : Top coordinate in metafile units</li>
- * <li>{@link #bottom} : Bottom coordinate in metafile units</li>
- * <li>{@link #inch} : Number of metafile units per inch</li>
+ * <li>{@link #mtType} : File type (0 : memory, 1 : disk)</li>
+ * <li>{@link #mtHeaderSize} : Size of header in WORDS (always 9)</li>
+ * <li>{@link #mtVersion} : Version of Microsoft Windows used</li>
+ * <li>{@link #mtSize} : Total size of the metafile in WORDs</li>
+ * <li>{@link #mtNoObjects} : Number of objects in the file</li>
+ * <li>{@link #mtMaxRecord} : The size of largest record in WORDs</li>
+ * <li>{@link #mtNoParameters} : Not Used (always 0)</li>
+ * <li>{@link #left} : Left coordinate in metafile units</li>
+ * <li>{@link #right} : Right coordinate in metafile units</li>
+ * <li>{@link #top} : Top coordinate in metafile units</li>
+ * <li>{@link #bottom} : Bottom coordinate in metafile units</li>
+ * <li>{@link #inch} : Number of metafile units per inch</li>
* </ul>
* <p>Then it calls the {@link #readRecords(DataInputStream)} abstract method,
* whose behavior is left to the subclass</p>.
@@ -337,9 +337,9 @@
int reserved = readInt( is );
short checksum = readShort( is );
width = right - left;
- height = bottom - top;
+ height = bottom - top;
} else {
- setReading( false );
+ setReading( false );
is.close();
throw new IOException( "Unable to read file, it is not a Aldus Placable Metafile" );
}
@@ -350,19 +350,19 @@
mtSize = readInt( is );
mtNoObjects = readShort( is );
mtMaxRecord = readInt( is );
- mtNoParameters = readShort( is );
-
+ mtNoParameters = readShort( is );
+
numObjects = mtNoObjects;
objectVector.ensureCapacity( numObjects );
for ( int i = 0; i < numObjects; i++ ) {
objectVector.addElement( new GdiObject( i, false ));
- }
-
+ }
+
boolean ret = readRecords(is);
is.close();
if (!ret) throw new IOException("Unhandled exception while reading records");
}
-
+
public int addObject( int type, Object obj ){
int startIdx = 0;
// if ( type == Wmf.PEN ) {
@@ -376,7 +376,7 @@
break;
}
}
-
+
return lastObjectIdx;
}
@@ -401,21 +401,21 @@
break;
}
}
-
+
return idx;
}
-
+
/**
* Returns a GdiObject from the handle table
*/
public GdiObject getObject( int idx ) {
return (GdiObject)objectVector.elementAt( idx );
- }
-
+ }
+
/**
* Returns the number of GdiObjects in the handle table
*/
public int getNumObjects() {
return numObjects;
- }
-}
\ No newline at end of file
+ }
+}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/MetaRecord.java Thu Nov 16 03:16:05 2006
@@ -22,8 +22,8 @@
import java.util.Vector;
public class MetaRecord /*implements Serializable*/ {
- public int functionId;
- public int numPoints;
+ public int functionId;
+ public int numPoints;
private Vector ptVector;
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/transcoder/wmf/tosvg/RecordStore.java Thu Nov 16 03:16:05 2006
@@ -269,8 +269,8 @@
transient protected int numObjects;
transient public int lastObjectIdx;
transient protected int vpX, vpY, vpW, vpH;
- transient protected Vector records;
- transient protected Vector objectVector;
+ transient protected Vector records;
+ transient protected Vector objectVector;
transient protected boolean bReading = false;
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/Base64DecodeStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/Base64DecodeStream.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/Base64DecodeStream.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/Base64DecodeStream.java Thu Nov 16 03:16:05 2006
@@ -52,7 +52,7 @@
InputStream src;
public Base64DecodeStream(InputStream src) {
- this.src = src;
+ this.src = src;
}
private final static byte pem_array[] = new byte[256];
@@ -67,7 +67,7 @@
for (char c='a'; c<='z'; c++) {
pem_array[c] = (byte)idx++;
}
-
+
for (char c='0'; c<='9'; c++) {
pem_array[c] = (byte)idx++;
}
@@ -150,7 +150,7 @@
b = pem_array[((int)decode_buffer[1])&0xFF];
c = pem_array[((int)decode_buffer[2])&0xFF];
d = pem_array[((int)decode_buffer[3])&0xFF];
-
+
out_buffer[0] = (byte)((a<<2) | (b>>>4));
out_buffer[1] = (byte)((b<<4) | (c>>>2));
out_buffer[2] = (byte)((c<<6) | d );
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/DoublyLinkedList.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/DoublyLinkedList.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/DoublyLinkedList.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/DoublyLinkedList.java Thu Nov 16 03:16:05 2006
@@ -30,62 +30,62 @@
/**
* Basic doubly linked list node interface.
*/
- public static class Node {
- private Node next = null;
- private Node prev = null;
-
- public final Node getNext() { return next; }
- public final Node getPrev() { return prev; }
-
- protected final void setNext(Node newNext) { next = newNext; }
- protected final void setPrev(Node newPrev) { prev = newPrev; }
+ public static class Node {
+ private Node next = null;
+ private Node prev = null;
+
+ public final Node getNext() { return next; }
+ public final Node getPrev() { return prev; }
+
+ protected final void setNext(Node newNext) { next = newNext; }
+ protected final void setPrev(Node newPrev) { prev = newPrev; }
/**
* Unlink this node from it's current list...
*/
- protected final void unlink() {
- if (getNext() != null)
- getNext().setPrev(getPrev());
- if (getPrev() != null)
- getPrev().setNext(getNext());
-
- setNext(null);
- setPrev(null);
- }
-
+ protected final void unlink() {
+ if (getNext() != null)
+ getNext().setPrev(getPrev());
+ if (getPrev() != null)
+ getPrev().setNext(getNext());
+
+ setNext(null);
+ setPrev(null);
+ }
+
/**
* Link this node in, infront of nde (unlinks it's self
* before hand if needed).
* @param nde the node to link in before.
*/
- protected final void insertBefore(Node nde) {
- // Already here...
- if (this == nde) return;
+ protected final void insertBefore(Node nde) {
+ // Already here...
+ if (this == nde) return;
- if (getPrev() != null)
+ if (getPrev() != null)
unlink();
-
- // Actually insert this node...
- if (nde == null) {
- // empty lst...
- setNext(this);
- setPrev(this);
- } else {
- setNext(nde);
- setPrev(nde.getPrev());
- nde.setPrev(this);
+
+ // Actually insert this node...
+ if (nde == null) {
+ // empty lst...
+ setNext(this);
+ setPrev(this);
+ } else {
+ setNext(nde);
+ setPrev(nde.getPrev());
+ nde.setPrev(this);
if (getPrev() != null)
getPrev().setNext(this);
- }
- }
- }
+ }
+ }
+ }
private Node head = null;
private int size = 0;
-
+
public DoublyLinkedList() {}
-
+
/**
* Returns the number of elements currently in the list.
*/
@@ -97,7 +97,7 @@
public synchronized void empty() {
while(size > 0) pop();
}
-
+
/**
* Get the current head element
* @return The current 'first' element in list.
@@ -152,8 +152,8 @@
head = nde;
size++;
}
-
- /**
+
+ /**
* Removes nde from the list it is part of (should be this
* one, otherwise results are undefined). If nde is the
* current head element, then the next element becomes head,
@@ -178,7 +178,7 @@
*/
public Node pop() {
if (head == null) return null;
-
+
Node nde = head;
remove(nde);
return nde;
@@ -190,7 +190,7 @@
*/
public Node unpush() {
if (head == null) return null;
-
+
Node nde = getTail();
remove(nde);
return nde;
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/EncodingUtilities.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/EncodingUtilities.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/EncodingUtilities.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/EncodingUtilities.java Thu Nov 16 03:16:05 2006
@@ -60,7 +60,7 @@
ENCODINGS.put("EBCDIC-CP-US", "Cp037");
ENCODINGS.put("EBCDIC-CP-CA", "Cp037");
ENCODINGS.put("EBCDIC-CP-NL", "Cp037");
- ENCODINGS.put("EBCDIC-CP-WT", "Cp037");
+ ENCODINGS.put("EBCDIC-CP-WT", "Cp037");
ENCODINGS.put("EBCDIC-CP-DK", "Cp277");
ENCODINGS.put("EBCDIC-CP-NO", "Cp277");
ENCODINGS.put("EBCDIC-CP-FI", "Cp278");
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/PreferenceManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/PreferenceManager.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/PreferenceManager.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/PreferenceManager.java Thu Nov 16 03:16:05 2006
@@ -842,8 +842,8 @@
if (getDefault(key) != null &&
((Boolean)getDefault(key)).booleanValue() != value) {
internal.setProperty(key, value?"true":"false");
- } else {
+ } else {
internal.remove(key);
- }
+ }
}
}
Modified: xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/CSSMediaPanel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/CSSMediaPanel.java?view=diff&rev=475685&r1=475684&r2=475685
==============================================================================
--- xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/CSSMediaPanel.java (original)
+++ xmlgraphics/batik/trunk/sources/org/apache/batik/util/gui/CSSMediaPanel.java Thu Nov 16 03:16:05 2006
@@ -116,63 +116,63 @@
* Constructs a new panel to edit CSS media.
*/
public CSSMediaPanel() {
- super(new GridBagLayout());
+ super(new GridBagLayout());
- listeners.put("AddButtonAction", new AddButtonAction());
- listeners.put("RemoveButtonAction", new RemoveButtonAction());
- listeners.put("ClearButtonAction", new ClearButtonAction());
-
- setBorder(BorderFactory.createTitledBorder
- (BorderFactory.createEtchedBorder(),
- resources.getString("Panel.title")));
-
- ExtendedGridBagConstraints constraints =
- new ExtendedGridBagConstraints();
-
- constraints.insets = new Insets(5, 5, 5, 5);
-
- mediaList = new JList();
- mediaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- mediaList.setModel(listModel);
- mediaList.addListSelectionListener(new MediaListSelectionListener());
- listModel.addListDataListener(new MediaListDataListener());
-
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
- constraints.weightx = 1.0;
- constraints.weighty = 1.0;
- constraints.fill = GridBagConstraints.BOTH;
- constraints.setGridBounds(0, 0, 1, 3);
- scrollPane.getViewport().add(mediaList);
- add(scrollPane, constraints);
-
- ButtonFactory bf = new ButtonFactory(bundle, this);
- constraints.weightx = 0;
- constraints.weighty = 0;
- constraints.fill = GridBagConstraints.HORIZONTAL;
- constraints.anchor = GridBagConstraints.NORTH;
-
- addButton = bf.createJButton("AddButton");
- constraints.setGridBounds(1, 0, 1, 1);
- add(addButton, constraints);
-
- removeButton = bf.createJButton("RemoveButton");
- constraints.setGridBounds(1, 1, 1, 1);
- add(removeButton, constraints);
-
- clearButton = bf.createJButton("ClearButton");
- constraints.setGridBounds(1, 2, 1, 1);
- add(clearButton, constraints);
+ listeners.put("AddButtonAction", new AddButtonAction());
+ listeners.put("RemoveButtonAction", new RemoveButtonAction());
+ listeners.put("ClearButtonAction", new ClearButtonAction());
+
+ setBorder(BorderFactory.createTitledBorder
+ (BorderFactory.createEtchedBorder(),
+ resources.getString("Panel.title")));
+
+ ExtendedGridBagConstraints constraints =
+ new ExtendedGridBagConstraints();
+
+ constraints.insets = new Insets(5, 5, 5, 5);
+
+ mediaList = new JList();
+ mediaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ mediaList.setModel(listModel);
+ mediaList.addListSelectionListener(new MediaListSelectionListener());
+ listModel.addListDataListener(new MediaListDataListener());
+
+ JScrollPane scrollPane = new JScrollPane();
+ scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
+ constraints.weightx = 1.0;
+ constraints.weighty = 1.0;
+ constraints.fill = GridBagConstraints.BOTH;
+ constraints.setGridBounds(0, 0, 1, 3);
+ scrollPane.getViewport().add(mediaList);
+ add(scrollPane, constraints);
+
+ ButtonFactory bf = new ButtonFactory(bundle, this);
+ constraints.weightx = 0;
+ constraints.weighty = 0;
+ constraints.fill = GridBagConstraints.HORIZONTAL;
+ constraints.anchor = GridBagConstraints.NORTH;
+
+ addButton = bf.createJButton("AddButton");
+ constraints.setGridBounds(1, 0, 1, 1);
+ add(addButton, constraints);
+
+ removeButton = bf.createJButton("RemoveButton");
+ constraints.setGridBounds(1, 1, 1, 1);
+ add(removeButton, constraints);
+
+ clearButton = bf.createJButton("ClearButton");
+ constraints.setGridBounds(1, 2, 1, 1);
+ add(clearButton, constraints);
- updateButtons();
+ updateButtons();
}
/**
* Updates the button states.
*/
protected void updateButtons() {
- removeButton.setEnabled(!mediaList.isSelectionEmpty());
- clearButton.setEnabled(!listModel.isEmpty());
+ removeButton.setEnabled(!mediaList.isSelectionEmpty());
+ clearButton.setEnabled(!listModel.isEmpty());
}
/**
@@ -181,11 +181,11 @@
* @param mediaList the list of media to edit
*/
public void setMedia(List mediaList) {
- listModel.removeAllElements();
- Iterator iter = mediaList.iterator();
- while (iter.hasNext()) {
- listModel.addElement(iter.next());
- }
+ listModel.removeAllElements();
+ Iterator iter = mediaList.iterator();
+ while (iter.hasNext()) {
+ listModel.addElement(iter.next());
+ }
}
/**
@@ -195,36 +195,36 @@
* @param media the media separated by space
*/
public void setMedia(String media) {
- listModel.removeAllElements();
- StringTokenizer tokens = new StringTokenizer(media, " ");
- while (tokens.hasMoreTokens()) {
- listModel.addElement(tokens.nextToken());
- }
+ listModel.removeAllElements();
+ StringTokenizer tokens = new StringTokenizer(media, " ");
+ while (tokens.hasMoreTokens()) {
+ listModel.addElement(tokens.nextToken());
+ }
}
/**
* Returns the list of media.
*/
public List getMedia() {
- List media = new ArrayList(listModel.size());
- Enumeration e = listModel.elements();
- while (e.hasMoreElements()) {
- media.add(e.nextElement());
- }
- return media;
+ List media = new ArrayList(listModel.size());
+ Enumeration e = listModel.elements();
+ while (e.hasMoreElements()) {
+ media.add(e.nextElement());
+ }
+ return media;
}
/**
* Returns the media list as a string separated by space.
*/
public String getMediaAsString() {
- StringBuffer buffer = new StringBuffer();
- Enumeration e = listModel.elements();
- while (e.hasMoreElements()) {
- buffer.append((String)e.nextElement());
- buffer.append(" ");
- }
- return buffer.toString();
+ StringBuffer buffer = new StringBuffer();
+ Enumeration e = listModel.elements();
+ while (e.hasMoreElements()) {
+ buffer.append((String)e.nextElement());
+ buffer.append(" ");
+ }
+ return buffer.toString();
}
/**
@@ -234,7 +234,7 @@
* @param title the title of this dialog
*/
public static int showDialog(Component parent, String title) {
- return showDialog(parent, title, "");
+ return showDialog(parent, title, "");
}
/**
@@ -245,13 +245,13 @@
* @param mediaList the list of media
*/
public static int showDialog(Component parent,
- String title,
- List mediaList) {
- Dialog dialog = new Dialog(parent, title, mediaList);
- dialog.setModal(true);
- dialog.pack();
- dialog.setVisible(true);
- return dialog.getReturnCode();
+ String title,
+ List mediaList) {
+ Dialog dialog = new Dialog(parent, title, mediaList);
+ dialog.setModal(true);
+ dialog.pack();
+ dialog.setVisible(true);
+ return dialog.getReturnCode();
}
/**
@@ -262,13 +262,13 @@
* @param media the list of media
*/
public static int showDialog(Component parent,
- String title,
- String media) {
- Dialog dialog = new Dialog(parent, title, media);
- dialog.setModal(true);
- dialog.pack();
- dialog.setVisible(true);
- return dialog.getReturnCode();
+ String title,
+ String media) {
+ Dialog dialog = new Dialog(parent, title, media);
+ dialog.setModal(true);
+ dialog.pack();
+ dialog.setVisible(true);
+ return dialog.getReturnCode();
}
/**
@@ -283,94 +283,94 @@
* @throws MissingListenerException if the action is not found
*/
public Action getAction(String key) throws MissingListenerException {
- return (Action)listeners.get(key);
+ return (Action)listeners.get(key);
}
/**
* The action associated with the 'Add' button
*/
protected class AddButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- AddMediumDialog dialog = new AddMediumDialog(CSSMediaPanel.this);
- dialog.pack();
- dialog.setVisible(true);
-
- if ((dialog.getReturnCode() == AddMediumDialog.CANCEL_OPTION) ||
- (dialog.getMedium() == null)) {
- return;
- }
-
- String medium = dialog.getMedium().trim();
- if (medium.length() == 0 || listModel.contains(medium)) {
- return;
- }
-
- for (int i = 0; i < listModel.size() && medium != null; ++i) {
- String s = (String)listModel.getElementAt(i);
- int c = medium.compareTo(s);
- if (c == 0) {
- medium = null;
- } else if (c < 0) {
- listModel.insertElementAt(medium, i);
- medium = null;
- }
- }
- if (medium != null) {
- listModel.addElement(medium);
- }
- }
+ public void actionPerformed(ActionEvent e) {
+ AddMediumDialog dialog = new AddMediumDialog(CSSMediaPanel.this);
+ dialog.pack();
+ dialog.setVisible(true);
+
+ if ((dialog.getReturnCode() == AddMediumDialog.CANCEL_OPTION) ||
+ (dialog.getMedium() == null)) {
+ return;
+ }
+
+ String medium = dialog.getMedium().trim();
+ if (medium.length() == 0 || listModel.contains(medium)) {
+ return;
+ }
+
+ for (int i = 0; i < listModel.size() && medium != null; ++i) {
+ String s = (String)listModel.getElementAt(i);
+ int c = medium.compareTo(s);
+ if (c == 0) {
+ medium = null;
+ } else if (c < 0) {
+ listModel.insertElementAt(medium, i);
+ medium = null;
+ }
+ }
+ if (medium != null) {
+ listModel.addElement(medium);
+ }
+ }
}
/**
* The action associated with the 'Remove' button
*/
protected class RemoveButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- int index = mediaList.getSelectedIndex();
- mediaList.clearSelection();
- if (index >= 0) {
- listModel.removeElementAt(index);
- }
- }
+ public void actionPerformed(ActionEvent e) {
+ int index = mediaList.getSelectedIndex();
+ mediaList.clearSelection();
+ if (index >= 0) {
+ listModel.removeElementAt(index);
+ }
+ }
}
/**
* The action associated with the 'Clear' button
*/
protected class ClearButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- mediaList.clearSelection();
- listModel.removeAllElements();
- }
+ public void actionPerformed(ActionEvent e) {
+ mediaList.clearSelection();
+ listModel.removeAllElements();
+ }
}
/**
* To manage selection modifications
*/
protected class MediaListSelectionListener
- implements ListSelectionListener {
+ implements ListSelectionListener {
- public void valueChanged(ListSelectionEvent e) {
- updateButtons();
- }
+ public void valueChanged(ListSelectionEvent e) {
+ updateButtons();
+ }
}
/**
* To manage data modifications in the media list.
*/
protected class MediaListDataListener implements ListDataListener {
-
- public void contentsChanged(ListDataEvent e) {
- updateButtons();
- }
-
- public void intervalAdded(ListDataEvent e) {
- updateButtons();
- }
-
- public void intervalRemoved(ListDataEvent e) {
- updateButtons();
- }
+
+ public void contentsChanged(ListDataEvent e) {
+ updateButtons();
+ }
+
+ public void intervalAdded(ListDataEvent e) {
+ updateButtons();
+ }
+
+ public void intervalRemoved(ListDataEvent e) {
+ updateButtons();
+ }
}
///////////////////////////////////////////////////////////////////////////
@@ -380,123 +380,123 @@
*/
public static class AddMediumDialog extends JDialog implements ActionMap {
- /**
- * The return value if 'OK' is chosen.
- */
- public final static int OK_OPTION = 0;
-
- /**
- * The return value if 'Cancel' is chosen.
- */
- public final static int CANCEL_OPTION = 1;
-
- /**
- * The new medium.
- */
- protected JComboBox medium;
-
- /**
- * The return code.
- */
- protected int returnCode;
-
- /**
- * Constructs a new AddMediumDialog.
- *
- * @param parent the parent of this dialog
- */
- public AddMediumDialog(Component parent) {
- super(JOptionPane.getFrameForComponent(parent),
- resources.getString("AddMediumDialog.title"));
- setModal(true);
-
- listeners.put("OKButtonAction", new OKButtonAction());
- listeners.put("CancelButtonAction", new CancelButtonAction());
-
- getContentPane().add(createContentPanel(), BorderLayout.CENTER);
- getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
- }
-
- /**
- * Returns the medium that might be added or null if any.
- */
- public String getMedium() {
- return (String)medium.getSelectedItem();
- }
-
- /**
- * Returns the panel to enter a new CSS medium.
- */
- protected Component createContentPanel() {
- JPanel panel = new JPanel(new BorderLayout());
- panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- panel.add(new JLabel(resources.getString("AddMediumDialog.label")),
- BorderLayout.WEST);
-
- medium = new JComboBox();
- medium.setEditable(true);
- String media = resources.getString("Media.list");
- StringTokenizer tokens = new StringTokenizer(media, " ");
- while (tokens.hasMoreTokens()) {
- medium.addItem(tokens.nextToken());
- }
- panel.add(medium, BorderLayout.CENTER);
- return panel;
- }
-
- /**
- * Returns the button panel.
- */
- protected Component createButtonsPanel() {
- JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- ButtonFactory bf = new ButtonFactory(bundle, this);
- panel.add(bf.createJButton("OKButton"));
- panel.add(bf.createJButton("CancelButton"));
- return panel;
- }
-
- /**
- * Returns the code that describes how the dialog has been closed (OK or
- * CANCEL).
- */
- public int getReturnCode() {
- return returnCode;
- }
-
- /**
- * The map that contains the listeners
- */
- protected Map listeners = new HashMap();
-
- /**
- * 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);
- }
-
- /**
- * The action associated with the 'OK' button
- */
- protected class OKButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- returnCode = OK_OPTION;
- dispose();
- }
- }
-
- /**
- * The action associated with the 'Cancel' button
- */
- protected class CancelButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- returnCode = CANCEL_OPTION;
- dispose();
- }
- }
+ /**
+ * The return value if 'OK' is chosen.
+ */
+ public final static int OK_OPTION = 0;
+
+ /**
+ * The return value if 'Cancel' is chosen.
+ */
+ public final static int CANCEL_OPTION = 1;
+
+ /**
+ * The new medium.
+ */
+ protected JComboBox medium;
+
+ /**
+ * The return code.
+ */
+ protected int returnCode;
+
+ /**
+ * Constructs a new AddMediumDialog.
+ *
+ * @param parent the parent of this dialog
+ */
+ public AddMediumDialog(Component parent) {
+ super(JOptionPane.getFrameForComponent(parent),
+ resources.getString("AddMediumDialog.title"));
+ setModal(true);
+
+ listeners.put("OKButtonAction", new OKButtonAction());
+ listeners.put("CancelButtonAction", new CancelButtonAction());
+
+ getContentPane().add(createContentPanel(), BorderLayout.CENTER);
+ getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns the medium that might be added or null if any.
+ */
+ public String getMedium() {
+ return (String)medium.getSelectedItem();
+ }
+
+ /**
+ * Returns the panel to enter a new CSS medium.
+ */
+ protected Component createContentPanel() {
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
+ panel.add(new JLabel(resources.getString("AddMediumDialog.label")),
+ BorderLayout.WEST);
+
+ medium = new JComboBox();
+ medium.setEditable(true);
+ String media = resources.getString("Media.list");
+ StringTokenizer tokens = new StringTokenizer(media, " ");
+ while (tokens.hasMoreTokens()) {
+ medium.addItem(tokens.nextToken());
+ }
+ panel.add(medium, BorderLayout.CENTER);
+ return panel;
+ }
+
+ /**
+ * Returns the button panel.
+ */
+ protected Component createButtonsPanel() {
+ JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ ButtonFactory bf = new ButtonFactory(bundle, this);
+ panel.add(bf.createJButton("OKButton"));
+ panel.add(bf.createJButton("CancelButton"));
+ return panel;
+ }
+
+ /**
+ * Returns the code that describes how the dialog has been closed (OK or
+ * CANCEL).
+ */
+ public int getReturnCode() {
+ return returnCode;
+ }
+
+ /**
+ * The map that contains the listeners
+ */
+ protected Map listeners = new HashMap();
+
+ /**
+ * 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);
+ }
+
+ /**
+ * The action associated with the 'OK' button
+ */
+ protected class OKButtonAction extends AbstractAction {
+ public void actionPerformed(ActionEvent e) {
+ returnCode = OK_OPTION;
+ dispose();
+ }
+ }
+
+ /**
+ * The action associated with the 'Cancel' button
+ */
+ protected class CancelButtonAction extends AbstractAction {
+ public void actionPerformed(ActionEvent e) {
+ returnCode = CANCEL_OPTION;
+ dispose();
+ }
+ }
}
///////////////////////////////////////////////////////////////////////////
@@ -505,129 +505,129 @@
* A dialog to edit/add/remove CSS media.
*/
public static class Dialog extends JDialog implements ActionMap {
-
- /**
- * The return value if 'OK' is chosen.
- */
- public final static int OK_OPTION = 0;
-
- /**
- * The return value if 'Cancel' is chosen.
- */
- public final static int CANCEL_OPTION = 1;
-
- /**
- * The return code.
- */
- protected int returnCode;
-
- /**
- * Constructs a new Dialog to edit/add/remove CSS media.
- */
- public Dialog() {
- this(null, "", "");
- }
-
- /**
- * Constructs a new Dialog to edit/add/remove CSS media.
- *
- * @param parent the parent of this dialog
- * @param title the title of this dialog
- * @param mediaList the media list
- */
- public Dialog(Component parent, String title, List mediaList) {
- super(JOptionPane.getFrameForComponent(parent), title);
-
- listeners.put("OKButtonAction", new OKButtonAction());
- listeners.put("CancelButtonAction", new CancelButtonAction());
-
- CSSMediaPanel panel = new CSSMediaPanel();
- panel.setMedia(mediaList);
- getContentPane().add(panel, BorderLayout.CENTER);
- getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
- }
-
- /**
- * Constructs a new Dialog to edit/add/remove CSS media.
- *
- * @param parent the parent of this dialog
- * @param title the title of this dialog
- * @param media the media list
- */
- public Dialog(Component parent, String title, String media) {
- super(JOptionPane.getFrameForComponent(parent), title);
-
- listeners.put("OKButtonAction", new OKButtonAction());
- listeners.put("CancelButtonAction", new CancelButtonAction());
-
- CSSMediaPanel panel = new CSSMediaPanel();
- panel.setMedia(media);
- getContentPane().add(panel, BorderLayout.CENTER);
- getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
- }
-
- /**
- * Returns the code that describes how the dialog has been closed (OK or
- * CANCEL).
- */
- public int getReturnCode() {
- return returnCode;
- }
-
- /**
- * Creates the OK/Cancel buttons panel
- */
- protected JPanel createButtonsPanel() {
- JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- ButtonFactory bf = new ButtonFactory(bundle, this);
- p.add(bf.createJButton("OKButton"));
- p.add(bf.createJButton("CancelButton"));
- return p;
- }
-
- /**
- * The map that contains the listeners
- */
- protected Map listeners = new HashMap();
-
- /**
- * 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);
- }
-
- /**
- * The action associated with the 'OK' button
- */
- protected class OKButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- returnCode = OK_OPTION;
- dispose();
- }
- }
-
- /**
- * The action associated with the 'Cancel' button
- */
- protected class CancelButtonAction extends AbstractAction {
- public void actionPerformed(ActionEvent e) {
- returnCode = CANCEL_OPTION;
- dispose();
- }
- }
+
+ /**
+ * The return value if 'OK' is chosen.
+ */
+ public final static int OK_OPTION = 0;
+
+ /**
+ * The return value if 'Cancel' is chosen.
+ */
+ public final static int CANCEL_OPTION = 1;
+
+ /**
+ * The return code.
+ */
+ protected int returnCode;
+
+ /**
+ * Constructs a new Dialog to edit/add/remove CSS media.
+ */
+ public Dialog() {
+ this(null, "", "");
+ }
+
+ /**
+ * Constructs a new Dialog to edit/add/remove CSS media.
+ *
+ * @param parent the parent of this dialog
+ * @param title the title of this dialog
+ * @param mediaList the media list
+ */
+ public Dialog(Component parent, String title, List mediaList) {
+ super(JOptionPane.getFrameForComponent(parent), title);
+
+ listeners.put("OKButtonAction", new OKButtonAction());
+ listeners.put("CancelButtonAction", new CancelButtonAction());
+
+ CSSMediaPanel panel = new CSSMediaPanel();
+ panel.setMedia(mediaList);
+ getContentPane().add(panel, BorderLayout.CENTER);
+ getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
+ }
+
+ /**
+ * Constructs a new Dialog to edit/add/remove CSS media.
+ *
+ * @param parent the parent of this dialog
+ * @param title the title of this dialog
+ * @param media the media list
+ */
+ public Dialog(Component parent, String title, String media) {
+ super(JOptionPane.getFrameForComponent(parent), title);
+
+ listeners.put("OKButtonAction", new OKButtonAction());
+ listeners.put("CancelButtonAction", new CancelButtonAction());
+
+ CSSMediaPanel panel = new CSSMediaPanel();
+ panel.setMedia(media);
+ getContentPane().add(panel, BorderLayout.CENTER);
+ getContentPane().add(createButtonsPanel(), BorderLayout.SOUTH);
+ }
+
+ /**
+ * Returns the code that describes how the dialog has been closed (OK or
+ * CANCEL).
+ */
+ public int getReturnCode() {
+ return returnCode;
+ }
+
+ /**
+ * Creates the OK/Cancel buttons panel
+ */
+ protected JPanel createButtonsPanel() {
+ JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ ButtonFactory bf = new ButtonFactory(bundle, this);
+ p.add(bf.createJButton("OKButton"));
+ p.add(bf.createJButton("CancelButton"));
+ return p;
+ }
+
+ /**
+ * The map that contains the listeners
+ */
+ protected Map listeners = new HashMap();
+
+ /**
+ * 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);
+ }
+
+ /**
+ * The action associated with the 'OK' button
+ */
+ protected class OKButtonAction extends AbstractAction {
+ public void actionPerformed(ActionEvent e) {
+ returnCode = OK_OPTION;
+ dispose();
+ }
+ }
+
+ /**
+ * The action associated with the 'Cancel' button
+ */
+ protected class CancelButtonAction extends AbstractAction {
+ public void actionPerformed(ActionEvent e) {
+ returnCode = CANCEL_OPTION;
+ dispose();
+ }
+ }
}
/**
* Main - debug -
*/
public static void main(String [] args) {
- String media = "all aural braille embossed handheld print projection screen tty tv";
- int code = CSSMediaPanel.showDialog(null, "Test", media);
- System.out.println(code);
- System.exit(0);
+ String media = "all aural braille embossed handheld print projection screen tty tv";
+ int code = CSSMediaPanel.showDialog(null, "Test", media);
+ System.out.println(code);
+ System.exit(0);
}
}