deweese 2002/06/26 18:37:16 Modified: resources/org/apache/batik/apps/svgbrowser/resources GUI.properties sources/org/apache/batik/apps/svgbrowser JPEGOptionPanel.java JSVGViewerFrame.java Added: sources/org/apache/batik/apps/svgbrowser OptionPanel.java PNGOptionPanel.java Log: Contribution by Jun Inamori San, of an Options dialog for writing 256 color Indexed PNGs from squiggle. Revision Changes Path 1.53 +9 -1 xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties Index: GUI.properties =================================================================== RCS file: /home/cvs/xml-batik/resources/org/apache/batik/apps/svgbrowser/resources/GUI.properties,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- GUI.properties 17 Jun 2002 08:07:38 -0000 1.52 +++ GUI.properties 27 Jun 2002 01:37:16 -0000 1.53 @@ -529,6 +529,14 @@ JPEGOptionPanel.label = Quality: # +# PNGOptionPanel +# + +OKButton.text = OK +PNGOptionPanel.dialog.title = Write 256 color PNG? +PNGOptionPanel.label = Reduce image to 256 color indexed PNG?: + +# # About Box parameters # AboutDialog.icon.apache.logo = org/apache/batik/apps/svgbrowser/resources/asf-logo.jpg 1.2 +8 -98 xml-batik/sources/org/apache/batik/apps/svgbrowser/JPEGOptionPanel.java Index: JPEGOptionPanel.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JPEGOptionPanel.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JPEGOptionPanel.java 15 Oct 2001 14:40:15 -0000 1.1 +++ JPEGOptionPanel.java 27 Jun 2002 01:37:16 -0000 1.2 @@ -8,32 +8,19 @@ package org.apache.batik.apps.svgbrowser; -import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; -import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; -import java.awt.event.ActionEvent; - import java.util.Hashtable; -import java.util.Locale; -import java.util.ResourceBundle; -import javax.swing.AbstractAction; -import javax.swing.Action; import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JDialog; import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; import javax.swing.JSlider; import org.apache.batik.util.gui.ExtendedGridBagConstraints; -import org.apache.batik.util.gui.resource.ResourceManager; /** * This class represents a panel to control jpeg encoding quality. @@ -41,29 +28,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Thierry Kormann</a> * @version $Id$ */ -public class JPEGOptionPanel extends JPanel { - - /** - * The gui resources file name - */ - public final static String RESOURCES = - "org.apache.batik.apps.svgbrowser.resources.GUI"; - - /** - * 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); - } - +public class JPEGOptionPanel extends OptionPanel { /** * The jpeg encoding quality. */ @@ -119,71 +84,16 @@ return quality.getValue()/100f; } - public static void main(String [] args) { - System.out.println(showDialog(null)); - } - /** - * Shows a dialog to choose the jpeg encoding quality and return the quality - * as a float. + * Shows a dialog to choose the jpeg encoding quality and return + * the quality as a float. */ public static float showDialog(Component parent) { - Dialog dialog = new Dialog(parent); + String title = resources.getString("JPEGOptionPanel.dialog.title"); + JPEGOptionPanel panel = new JPEGOptionPanel(); + Dialog dialog = new Dialog(parent, title, panel); dialog.pack(); dialog.show(); - return dialog.getQuality(); - } - - /** - * This class is modal dialog to choose the jpeg encoding quality. - */ - public static class Dialog extends JDialog { - - /** - * The 'ok' button. - */ - protected JButton ok; - - /** - * The 'ok' button. - */ - protected JPEGOptionPanel panel; - - public Dialog(Component parent) { - super(JOptionPane.getFrameForComponent(parent), - resources.getString("JPEGOptionPanel.dialog.title")); - setModal(true); - panel = new JPEGOptionPanel(); - getContentPane().add(panel, BorderLayout.CENTER); - getContentPane().add(createButtonPanel(), BorderLayout.SOUTH); - } - - /** - * Returns the jpeg quality. - */ - public float getQuality() { - return panel.getQuality(); - } - - /** - * Creates the button panel. - */ - protected JPanel createButtonPanel() { - JPanel panel = new JPanel(new FlowLayout()); - ok = new JButton(resources.getString("OKButton.text")); - ok.addActionListener(new OKButtonAction()); - panel.add(ok); - return panel; - } - - /** - * The action associated to the 'ok' button. - */ - protected class OKButtonAction extends AbstractAction { - - public void actionPerformed(ActionEvent evt) { - dispose(); - } - } + return panel.getQuality(); } } 1.82 +15 -1 xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java Index: JSVGViewerFrame.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/JSVGViewerFrame.java,v retrieving revision 1.81 retrieving revision 1.82 diff -u -r1.81 -r1.82 --- JSVGViewerFrame.java 18 Jun 2002 12:27:11 -0000 1.81 +++ JSVGViewerFrame.java 27 Jun 2002 01:37:16 -0000 1.82 @@ -1086,6 +1086,12 @@ int choice = fileChooser.showSaveDialog(JSVGViewerFrame.this); if (choice == JFileChooser.APPROVE_OPTION) { + + // Start: By Jun Inamori ([EMAIL PROTECTED]) + boolean isIndexed = + PNGOptionPanel.showDialog(JSVGViewerFrame.this); + // End: By Jun Inamori ([EMAIL PROTECTED]) + final File f = fileChooser.getSelectedFile(); BufferedImage buffer = svgCanvas.getOffScreen(); if (buffer != null) { @@ -1100,6 +1106,14 @@ application.getXMLParserClassName()); trans.addTranscodingHint(PNGTranscoder.KEY_FORCE_TRANSPARENT_WHITE, new Boolean(true)); + + // Start: By Jun Inamori + if(isIndexed){ + trans.addTranscodingHint + (PNGTranscoder.KEY_INDEXED,new Boolean(true)); + } + // End: By Jun Inamori + final BufferedImage img = trans.createImage(w, h); // paint the buffer to the image 1.1 xml-batik/sources/org/apache/batik/apps/svgbrowser/OptionPanel.java Index: OptionPanel.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.apps.svgbrowser; import java.awt.BorderLayout; import java.awt.Component; import java.awt.FlowLayout; import java.awt.LayoutManager; import java.awt.event.ActionEvent; import java.util.Locale; import java.util.ResourceBundle; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JOptionPane; import javax.swing.JPanel; import org.apache.batik.util.gui.resource.ResourceManager; /** * This class represents a panel to present users with options. * * @author <a href="mailto:[EMAIL PROTECTED]">Thomas DeWeese</a> * @version $Id: OptionPanel.java,v 1.1 2002/06/27 01:37:16 deweese Exp $ */ public class OptionPanel extends JPanel { /** * The gui resources file name */ public final static String RESOURCES = "org.apache.batik.apps.svgbrowser.resources.GUI"; /** * 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); } /** * Creates a new panel. */ public OptionPanel(LayoutManager layout) { super(layout); } /** * This class is modal dialog to choose the jpeg encoding quality. */ public static class Dialog extends JDialog { /** * The 'ok' button. */ protected JButton ok; /** * The 'ok' button. */ protected JPanel panel; public Dialog(Component parent, String title, JPanel panel) { super(JOptionPane.getFrameForComponent(parent), title); setModal(true); this.panel = panel; getContentPane().add(panel, BorderLayout.CENTER); getContentPane().add(createButtonPanel(), BorderLayout.SOUTH); } /** * Creates the button panel. */ protected JPanel createButtonPanel() { JPanel panel = new JPanel(new FlowLayout()); ok = new JButton(resources.getString("OKButton.text")); ok.addActionListener(new OKButtonAction()); panel.add(ok); return panel; } /** * The action associated to the 'ok' button. */ protected class OKButtonAction extends AbstractAction { public void actionPerformed(ActionEvent evt) { dispose(); } } } } 1.1 xml-batik/sources/org/apache/batik/apps/svgbrowser/PNGOptionPanel.java Index: PNGOptionPanel.java =================================================================== /***************************************************************************** * Copyright (C) The Apache Software Foundation. All rights reserved. * * ------------------------------------------------------------------------- * * This software is published under the terms of the Apache Software License * * version 1.1, a copy of which has been included with this distribution in * * the LICENSE file. * *****************************************************************************/ package org.apache.batik.apps.svgbrowser; import java.awt.Component; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import javax.swing.JLabel; import javax.swing.JCheckBox; import org.apache.batik.util.gui.ExtendedGridBagConstraints; /** * This class represents a panel to choose the color model * of the PNG, i.e. RGB or INDEXED. * * @author <a href="mailto:[EMAIL PROTECTED]">Jun Inamori</a> * */ public class PNGOptionPanel extends OptionPanel { /** * The check box for outputing an indexed PNG. */ protected JCheckBox check; /** * Creates a new panel. */ public PNGOptionPanel() { 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("PNGOptionPanel.label")), constraints); check=new JCheckBox(); constraints.weightx = 1.0; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.setGridBounds(1, 0, 1, 1); add(check, constraints); } /** * Returns if indexed or not */ public boolean isIndexed() { return check.isSelected(); } /** * Shows a dialog to choose the indexed PNG. */ public static boolean showDialog(Component parent) { String title = resources.getString("PNGOptionPanel.dialog.title"); PNGOptionPanel panel = new PNGOptionPanel(); Dialog dialog = new Dialog(parent, title, panel); dialog.pack(); dialog.show(); return panel.isIndexed(); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]